SDKits / ExamineX

Issue tracker for ExamineX
https://examinex.online
5 stars 0 forks source link

Long Range queries are not working correctly #101

Closed bielu closed 4 months ago

bielu commented 4 months ago

hi @Shazwazza, This query:

+(+x__IndexType:content) +x__Published:y +(+(filterId ge 638500320000000000 and filterId  le 638396640000000000) (filterId_en-gb ge 638500320000000000 and filterId_en-gb le 638396640000000000)) -hideFromSearch:1 +spath:1235

is translated to:

 ((search.ismatchscoring('x__IndexType:content', '', 'full', 'any')) and search.ismatchscoring('x__Published:y', '', 'full', 
'any') and (((filterId ge 638500320000000000 and filterId le 638396640000000000) or (filterId_en-gb ge 638500320000000000 and filterId_en-gb le 638396640000000000))) and not search.ismatchscoring('hideFromSearch:1', '', 'full', 'any') and search.ismatchscoring('spath:1235', '', 'full', 'any'))

which is incorrect in azure search. Query was build in this way:

query.And(x=>x.RangeQuery<long>((string[]) new string[2]
      {
        (string) filterId,
        (string) string.Concat(filterId, "_", ((string) culture)?.ToLowerInvariant())
      }, min, max))

where min and max are long values , the same query works on normal examine, when on azure it throws: {"error":{"code":"","message":"Invalid expression: ')' or operator expected at position 232 in '

Shazwazza commented 4 months ago

Any reason to not use DateTime instead of long? I'm the meantime I can see if I can replicate.

bielu commented 4 months ago

with lucene indexes it wasnt working fully on datetime and ticsk worked better, now we switch it might be option to try on examinex, when using datetime do i need index my field in any specific format?

Shazwazza commented 4 months ago

I can replicate - the issue is with the field name re-formatting for culture fields. The field formatting: filterId_en-gb is invalid in Azure Search and if you look at the definition of this field in the Azure Portal it will be: filterId_en_gb (no hyphen).

If you change your search to use that it should work (have replicated locally). ExamineX should take care of all of this input/output formatting for you, so looks like in this particular case it is being missed. I'll mark this as a bug and get a fix out asap. In the meantime, you can work around this by using the

ExamineX.Shared.IndexNaming.FormatFieldName or ExamineX.Shared.IndexNaming.TryFormatFieldName API to get the correct field name format to use in your RangeQuery field names.

Shazwazza commented 4 months ago

This is fixed in 6.0.1 published today https://github.com/SDKits/ExamineX/releases/tag/6.0.1

Shazwazza commented 4 months ago

@bielu everything working ok with that release?

bielu commented 4 months ago

Hey yes all worked