Special characters escaping with queryType: full

73 Views Asked by At

I am having issues while searching for terms with special charachters in it with queryType set to full. Take this example: https://learn.microsoft.com/en-us/azure/search/query-lucene-syntax#escaping-special-characters

If I use:

{
  "search": "https\:\/\/*",
  "queryType": "full",
  "highlight": "content"
}

I get the error FieldNotSearchable: Illegal arguments in query request: https is not a searchable field. This means that it's using https: as a field selector. Can someone explain too me why it's not excaping the :?

If I use

{
  "search": "https\:\/\/*",
  "queryType": "simple",
  "highlight": "content"
}

I got empty results, which is what I'm expecting

1

There are 1 best solutions below

0
JayashankarGS On

In the full queryType, the \ used does not escape the : character and is considered a Fielded search. It interprets it as https:// and gives an error, stating it is not searchable since you don't have https field. Refer to the documentation below for more information on Fielded search:

Lucene query syntax - Azure AI Search | Microsoft Learn

In the simple queryType, the Fielded search is not considered, and it searches for the entire string.

You can see the difference in results when searching for the field named street:

simple

enter image description here

full

enter image description here

In simple, it returns results for the word "street," but in full, it searches for the word "red" in the field street.

Therefore, in the full queryType, you need to use \\ to escape the characters.

{
  "search": "street\\:red",
  "queryType": "full",
  "highlight": "street"
}

This should return results for the word "street" since the : is escaped.

enter image description here

Searching for https\\:\\/\\/* will yield empty results.

enter image description here