Paul
May 24, 2019, 7:12pm
1
Hello,
how would I go about troubleshooting the reason FT.AGGREGATE isn’t returning data when using a certain query:
For instance using (@CheckNumber :(2019*))" returns no results:
“FT.AGGREGATE” “checks_hash_index_1” “(@CheckFromID :{3062}) (@CheckNumber :(2019*))” “APPLY” “@CheckID ” “AS” “CheckID” “APPLY” “@CheckDate ” “AS” “CheckDate” “APPLY” “@CreatedDateTimeUTC ” “AS” “CreatedDateTimeUTC” APPLY “@CheckNumber ” AS “CheckNumber” “SORTBY” “6” “@CheckDate ” “DESC” “@CreatedDateTimeUTC ” “DESC” “@CheckID ” “DESC”
``
whereas using (@CheckNumber :(201904*))" returns the correct ones:
“FT.AGGREGATE” “checks_hash_index_1” “(@CheckFromID :{3062}) (@CheckNumber :(201904*))” “APPLY” “@CheckID ” “AS” “CheckID” “APPLY” “@CheckDate ” “AS” “CheckDate” “APPLY” “@CreatedDateTimeUTC ” “AS” “CreatedDateTimeUTC” APPLY “@CheckNumber ” AS “CheckNumber” “SORTBY” “6” “@CheckDate ” “DESC” “@CreatedDateTimeUTC ” “DESC” “@CheckID ” “DESC”
``
(integer) 3
CheckID
“89825”
CheckDate
“6.36911424e+17”
CreatedDateTimeUTC
“6.36905194659e+17”
CheckNumber
“20190410\-3”
CheckID
“89824”
CheckDate
“6.36911424e+17”
CreatedDateTimeUTC
“6.36905194659e+17”
CheckNumber
“20190410\-2”
CheckID
“89823”
CheckDate
“6.36911424e+17”
CreatedDateTimeUTC
“6.36905194659e+17”
CheckNumber
“20190410\-1”
``
Here is part of the index, CheckNumber is TEXT SORTABLE:
ft.info checks_hash_index_1
index_name
checks_hash_index_1
index_options
“NOOFFSETS”
fields
CheckID
type
NUMERIC
SORTABLE
CheckNumber
type
TEXT
WEIGHT
“1”
SORTABLE
``
Thank you!
This is probably because the MAXEXPANSIONS value is to low. You need to increase it. See configuration section for more info: https://oss.redislabs.com/redisearch/Configuring.html
Paul
May 24, 2019, 7:28pm
3
I am using defaults for everything, and if I remove CheckFromID from the query string, I do get back some results:
“FT.SEARCH” “checks_hash_index_1” “(@CheckNumber :(2019*))” “APPLY” “@CheckID ” “AS” “CheckID” “APPLY” “@CheckDate ” “AS” “CheckDate” “APPLY” “@CreatedDateTimeUTC ” “AS” “CreatedDateTimeUTC” APPLY “@CheckNumber ” AS "CheckNumber
``
returns
(integer) 201
“99553”
CheckID
“99553”
CheckDate
“6.36941664e+17”
CreatedDateTimeUTC
“6.36941255821e+17”
CheckNumber
“20190522\-5173”
“99552”
CheckID
“99552”
CheckDate
“6.36941664e+17”
CreatedDateTimeUTC
“6.36941255821e+17”
CheckNumber
“20190522\-5172”
…
``
Paul
May 24, 2019, 7:30pm
4
Sorry that was FT.SEARCH, I was trying both, here is FT.AGGREGATE:
“FT.AGGREGATE” “checks_hash_index_1” “(@CheckNumber :(2019*))” “APPLY” “@CheckID ” “AS” “CheckID” “APPLY” “@CheckDate ” “AS” “CheckDate” “APPLY” “@CreatedDateTimeUTC ” “AS” “CreatedDateTimeUTC” APPLY “@CheckNumber ” AS “CheckNumber” “SORTBY” “6” “@CheckDate ” “DESC” “@CreatedDateTimeUTC ” “DESC” “@CheckID ” “DESC”
``
(integer) 201
CheckID
“99553”
CheckDate
“6.36941664e+17”
CreatedDateTimeUTC
“6.36941255821e+17”
CheckNumber
“20190522\-5173”
CheckID
“99552”
CheckDate
“6.36941664e+17”
CreatedDateTimeUTC
“6.36941255821e+17”
CheckNumber
“20190522\-5172”
…
``
This is just prove my assumption, increase the MAXEXPANSIONS and it will work.
Paul
May 24, 2019, 7:37pm
6
127.0.0.1:6379> FT.CONFIG SET MAXEXPANSIONS 1000000
OK
127.0.0.1:6379> “FT.AGGREGATE” “checks_hash_index_1” “(@CheckFromID :{3062}) (@CheckNumber :(2019*))” “APPLY” “@CheckID ” “AS” “CheckID” “APPLY” “@CheckDate ” “AS” “CheckDate” “APPLY” “@CreatedDateTimeUTC ” “AS” “CreatedDateTimeUTC” APPLY “@CheckNumber ” AS “CheckNumber” “SORTBY” “6” “@CheckDate ” “DESC” “@CreatedDateTimeUTC ” “DESC” “@CheckID ” “DESC”
(integer) 0
127.0.0.1:6379> FT.CONFIG GET MAXEXPANSIONS
MAXEXPANSIONS
1000000
``
Here is what I tried, I still get 0 results back:
Paul
May 24, 2019, 7:44pm
7
My mistake, dropping the index, recreating it and re-adding the data worked!
What does MAXEXPANSIONS do, and what should I set it to, especially in our production environments since it comes with a disclaimer: “Setting it too high can cause performance issues.”?
MAXEXPANSIONS tells us how deep we should go inside the TRIE data-structure in order to find prefixes, the deeper we go the more time it takes. In your case if MAXEXPANSIONS is to low it does not mean that we did not find any match prefix but it means that from all the match prefixes found there was no prefix that also satisfy the second condition (@CheckFromID :{3062}). In order to find prefixes that does satisfy the second condition we needed to go deeper.
There is no clear rule of the value that you should set, it mostly depends on the number of TERMS you have in the TRIE (the more terms you the bigger you need to set the MAXEXPANSIONS).