1
votes

In Azure Search I have an index that has a batch of documents. Documents are JSONs and one of the documents has the following fields (abriged):

{
  "id": "1638",
  "segment": "N",
  "segmentIndicator": 1.23,     
}

and some other documents where segment is present, but is null.

I issue a search request using POST, as described under the link. I am getting valid results for id and segmentIndicator using the requests like

{
    "search": "id:(\"1638\")",
    "queryType": "full",
    "searchMode": "all"
}
or
{
    "search": "segmentIndicator:(\"1.23\")",
    "queryType": "full",
    "searchMode": "all"
}

as they both return the desired document and nothing else. I am not able to change queryType and searchMode and an exact match to my search criteria is needed (no fuzzy / proximity search).

However, when I say

{
    "search": "segment:(\"N\")",
    "queryType": "full",
    "searchMode": "all"
}

I am getting an empty search result, while I expect the same document to be found. How I can alter my query so I can correctly find the document by segment parameter?

1
What analyzer are you using for the segment field, if any? Also, do you need to match on segment even if the case doesn't match (e.g. -- "n" and "N" should both match)? If case-sensitive exact matches are fine, why not use a filter?Bruce Johnston
@BruceJohnston - I just send this query as is. I am very new to this service so do not know how to see / use analyzers atm. I believe I need exact match, case sensitive.Askar Ibragimov

1 Answers

1
votes

While I'm not sure why the single letter doesn't match, I'd speculate that it's probably being treated as a stopword and eliminated during lexical analysis of the query. The search parameter is best used for true full-text search scenarios.

It sounds like what you need is the $filter parameter, which is a strict Boolean predicate that does exact (case-sensitive) matches on field values, including values of all data types (not just strings). You can find a good introduction to filters in Azure Cognitive Search here. The full syntax reference is here.

Here is an example of how to filter on a string field for an exact match with 'N':

segment eq 'N'