0

I have following records -

{

"RoleDetails": "0AC05D80-B1E2-4E13-B1E7-602F6C272117  pqr  1",

 "GroupDetails": "0AC05D80-B1E2-4E13-B1E7-602F6C272117  Abc Xyz  1",

},

{

 "RoleDetails": "0AC05D80-B1E2-4E13-B1E7-602F6C272117  pqr  1",

 "GroupDetails": "0AC05D80-B1E2-4E13-B1E7-602F6C272117 Â Abc Xyz 1 Â 1",

},

{

"RoleDetails": "0AC05D80-B1E2-4E13-B1E7-602F6C272117  pqr  1",

"GroupDetails": "0AC05D80-B1E2-4E13-B1E7-602F6C272117 Â Abc Xyz 2 Â 1",

},

{

"RoleDetails": "0AC05D80-B1E2-4E13-B1E7-602F6C272117  pqr  1",

"GroupDetails": "0AC05D80-B1E2-4E13-B1E7-602F6C272117  Abc Xyz 1 New  1",

}

1)

When I am using following filter -

&$filter=search.ismatch('Abc Xyz 1','GroupDetails','simple', 'all')

Returned = all records

Expecting = just two rows ("Abc Xyz 1" and "Abc Xyz 1 new")

2)

When I am using following filter -

&$filter=search.ismatch('Abc Xyz 2','GroupDetails','simple', 'all')

Returned = returning matched record i.e. one row ("Abc Xyz 2") which is expected

3)

But when using this filter -

&$filter=search.ismatch('Abc Xyz 1 new','GroupDetails','simple', 'all')

Returned = returning matched record i.e. one row ("Abc Xyz 1 new") which is expected

So why it is returning all records when searched "Abc Xyz 1" ?

Also note: I tried "simple" and "full" querytype

SOLUTION As per answer provided by Matthew Gotteiner, I modified the query like this -

&$filter=search.ismatch('"Abc Xyz 1"','GroupDetails','simple', 'all')

and it worked!

Anil Purswani
  • 1,857
  • 6
  • 35
  • 63

1 Answers1

3

Since you are looking for exact phrases you should use the phrase search operator by surrounding your query in double quotes. For example, instead of searching for Abc Xyz 1, you can search for "Abc Xyz 1".

Also, you only need to use the search.ismatch function if you are planning to combine the search with a filter using and. Otherwise, you can use the search parameter in the REST API or the searchText parameter in the .NET SDK

  • I am using search.ismatch in Filter and can't use it in search. Secondly, search.ismatch doesn't allows "double quotes" that's the reason I used 'single quotes' I am getting exception - Invalid expression: Syntax error: character '\"' is not valid at position 15 in 'search.ismatch'. Third, Why is it working fine with 'Abc Xyz 2' and not 'Abc Xyz 1' – Anil Purswani Feb 06 '18 at 03:55
  • @AnilPurswani It would help us if you could edit your question to include more details about how you're calling Azure Search. For example, are you using the REST API or .NET SDK? Also, why are you using search.ismatch? Do you intend to combine it with other filter clauses via 'and'? – Bruce Johnston Feb 06 '18 at 04:01
  • @AnilPurswani As for why 'Abc Xyz 2' works, this is because there is only one document that contains the term "2", while all of them contain the term "1". Your search terms are being tokenized because they are not in double quotes. You might find this article useful: https://learn.microsoft.com/azure/search/search-lucene-query-architecture – Bruce Johnston Feb 06 '18 at 04:03
  • @Mathew Gotteiner, Thanks it worked. I had updated the my answer with the solution provided – Anil Purswani Feb 06 '18 at 05:05