I am concerned that maybe the index being created is not compatible with the query that appears designed to take advantage of the index. The query uses âLOWER(relationKey)â, and the index is just based on ârelationKeysâ, since the documents are indexed by NON-lower-relationKeys, and the query is based on "LOWER(relationKey).
Is this a correct assumption or do I need to change the index?
If I need to change the index, could you give me some pointers as to what I need to change?
How can you test if the index is working as expected?
The following is Index definition. Query uses covered index.
CREATE INDEX ix20 ON default (DISTINCT ARRAY LOWER(relationKey) FOR relationKey IN relationKeys END, relationKeys) WHERE docType = âuserRelationâ;
SELECT relationKeys FROM default
WHERE docType = 'userRelation' AND ANY relationKey IN relationKeys SATISFIES LOWER(relationKey) = $1 END;
You can check the query plan and what index is using by adding EXPLAIN in front like below.
EXPLAIN SELECT relationKeys FROM default
WHERE docType = 'userRelation' AND ANY relationKey IN relationKeys SATISFIES LOWER(relationKey) = $1 END;
NOTE: relationKeys array is too big Indexer may skip indexing the key and log the document in indexer.log. If that is the case remove second index key (like below) and query does non-covered query and document Fetch.
CREATE INDEX ix20 ON default (DISTINCT ARRAY LOWER(relationKey) FOR relationKey IN relationKeys END) WHERE docType = 'userRelation';
NOTE: relationKeys array is too bit Indexer may skip indexing the key and log the document in indexer.log. If that is the case remove second index key (like below) and query does non-covered query and document Fetch.
What is relationKeys is too bit?
When will the indexer skips indexing the key? Is it when you perform the query?