Search code examples
azurelucenelucene.netazure-cognitive-searchazure-search-.net-sdk

AZURE SEARCH, ismatch not filtering


I'm using Azure Search for perform some customs search in a database.

I got this one field that have this kind of structure:

"STUFF": "05-05-16-00|"

but I'm having trouble by creating the filter, because its possible that I'll not have all the numbers that builds this structure. It all depends that what the final user will type. So I need a wildcard to fill the blanks with the missing numbers, like this

"05-05-??-??" -> the pipe is important, because this field can have more than 1 code inside.

Now I need to catch all the possible elements that STARTS WITH 05-05, like, for example: 05-05-11-01

I thought I suposed to use the search.ismatch() function, but it doesnt work.

here some code:

search.ismatch('05-05-??-??','STUFF');

And the results were:

"STUFF": "02-02-16-00|",
"STUFF": "02-02-14-00|",

this is driving me crazy, because I dont know why this results came back.

Maybe is important to know that Im performing a POST request to the Azure Search API with this code in 'filter'

Maybe i should to escape this especial characters like - and ? like this

search.ismatch('05\\-05\\-\\?\\?\\-\\?\\?','STUFF')

But the results were the same.

Can somebody please help me ?

EDIT 1

following this Article I change some things and make the following search:

search.ismatch('\"05-00*\"','STUFF','simple', 'all')

And I starting the get some results, but now this is my results:

"STUFF": "06-05-02-00|", //WRONG
"STUFF": "05-02-05-01|", //RIGHT
"STUFF": "05-02-02-07|", //RIGHT

For some reason, it's returing the right structure but not the in the front of the text.

EDIT 2

I made some changes and change all the "-" for the keyword "OU" and I'm trying to follow this question to make sore like a "contains", but i perfoming a POST request with the following parameters

{
    "search": "*",
    "filter": "search.ismatch('/.*08010000OU/.*','STUFF', 'full', 'all')",
    "skip": "0",
    "count": true
}

Im trying to use a wildcard in the begining of the query search because I still missing some information.


Solution

  • I believe you won't be able to solve this using the StandardAnalyzer. Try switching to WhitespaceAnalyzer for this particular field and it probably will work with "05-05*"