1

I need to fetch Azure search results from the folderPath field as below: "folderPath": "xxxxxxxxxxxxx_85ba0b45-xxxxx-4d83-a7e6-xxxxxx/abc"

The results should be retrieved only from the above-mentioned folder.

But search service also includes results from folderpaths such as below. "xxxxxxxxxxxxx_85ba0b45-xxxxx-4d83-a7e6-xxxxxx/abc def" and "xxxxxxxxxxxxx_85ba0b45-xxxxx-4d83-a7e6-xxxxxx/abc xyz"

How do I fetch results only from the /abc folderPath?

  • 1
    Please provide some code if you have tried? I do not know about `Azure` but someone else may help you surly, if you show them some effort on your question. – Sinto Sep 12 '18 at 12:54
  • I'd suggest you look creating a custom analyzer for this field that specifically targets your use case. If you only want to match on the full folder name, I'd recommend you tokenize on "\", but not spaces. That should give you what you are looking for. More info: https://learn.microsoft.com/en-us/rest/api/searchservice/custom-analyzers-in-azure-search – Mike Carter - MSFT Sep 14 '18 at 19:06

1 Answers1

1

For this type of scenarios where you want the whole content of the field to match you should use Filters. Filters are documented at https://learn.microsoft.com/en-us/azure/search/search-filters .

Note that your folderpath field needs to be marked as "Filterable" before you start indexing.

You will need to specify your filter something like:

$filter=path eq 'xxxxxxxxxxxxx_85ba0b45-xxxxx-4d83-a7e6-xxxxxx/abc'&querytype=full  
Zoe
  • 27,060
  • 21
  • 118
  • 148
Luis Cabrera
  • 516
  • 3
  • 6
  • Firstly, thank you for the answer. I have tried filters and I can get the results as you said. Along with these results I should also include subfolder values. What I want: folderPath Results: xxx-xxxx/abc and Sub folderPath Results: xxx-xxxx/abc/pqr But what I am getting with filter: is only results from xxx-xxxx/abc if I include folderPath in search query string I am getting: xxx-xxxx/abc and xxx-xxxx/abc def (abc def is unwanted folder) – Ravi Talveda Sep 12 '18 at 19:18
  • You can combine filter values. $filter=search.ismatchscoring('dirictory_A | directoryB', 'path') Please take a look at https://learn.microsoft.com/en-us/azure/search/search-filters#filter-design-patterns – Luis Cabrera Sep 28 '18 at 17:28