Umer Qureshi
Umer Qureshi

Reputation: 1766

Azure Cognitive Search: Stop white-spaces to act like separator

We have some PDF files in azure storage and indexing is applied on it. when azure searched is performed using single search keyword e.g.

/docs?search=TG105&searchFields=content&highlight=content

it will return snippet of all the places where keyword TG105 is found. This result is expected so its good.

But when searched is performed with a full sentence e.g.

/docs?search=What is TG105&searchFields=content&highlight=content

it will return the text snippets where each single keyword what, is, TG105 is found separately in the content.

lets say there is a sentence SIM card is not inserted it will return in highlight list as SIM card <em>is</em> not inserted.

Now the question is how to do full sentence search, so that it highlight only where "what is TG105" is found?

Upvotes: 0

Views: 629

Answers (1)

gsubiran
gsubiran

Reputation: 2462

You just need to put your search phrase inside quotation marks (Phrase search operator) so your query should be something like:

/docs?search="What is TG105"&searchFields=content&highlight=content

This will return all documents containing this exact phrase (case insensitive) and the following higlight:

{
...
"@search.highlights": {
            "content": [
                "whatever <em>What</em> <em>is</em> <em>TG105</em> whatever"
            ]
        }
...
}

Important: You will not get results for documents containing something like this:

What is the TG105

To take care about this is time to play with queryType=fulland full lucene syntax Proximity search

Upvotes: 1

Related Questions