microsoft / AzureSearch_JFK_Files

This repo contains the sample code of the Azure Search and Cognitive Services used to provide insights and analysis around the JFK Files.
MIT License
389 stars 225 forks source link

Filter on single feature #133

Open Emix26 opened 1 year ago

Emix26 commented 1 year ago

Hi there, Thanks for this nice tool to get familiar to Azure cognitive skills. I have a question related to the checkbox list on the left. I would like to filter based on feature of the path of the documents. I managed to extract the path from the metadata and feed it to the checkbox list. However, when I click nothing happens. I think it's related to the filter that runs in the background when clicking on a checkbox. I think it's related to this specific line: https://github.com/microsoft/AzureSearch_JFK_Files/blob/3ee978559c31ddd8296111d12287d693e8947877/frontend/src/pages/search-page/service/jfk/mapper.search.ts#L165 Where this expects a collection of strings while the path is a single string. Am I correct ? If yes, how do I change that such that the filter accepts the path as input ?

Careyjmac commented 1 year ago

I believe the "filter" list as implemented actually uses the faceting feature of Azure Cognitive Search, so you would need to change the metadata field in your index to be facetable in order for this to work. References: https://github.com/microsoft/AzureSearch_JFK_Files/blob/3ee978559c31ddd8296111d12287d693e8947877/JfkWebApiSkills/JfkInitializer/SearchResources.cs#L323

Emix26 commented 1 year ago

Thanks for your answer. Indeed, I think so too. But to filter on the file path, I added this search field:

new SearchField("filePath", SearchFieldDataType.String) { IsSearchable = false, IsFilterable = true, IsHidden = false, IsSortable = false, IsFacetable = true  },

This seems to work as the filepaths are properly displayed on the left pannel. However, when I click on one of the checkbox, nothing happens (the checkboxes disappear and the result of the query as well). This lead me to believe that there is an issue with the fact that the filter expects a list or a collection of string, while I'm now passing only one string. Is there a way to filter on that string alone ? The behaviour that I would like is that when I click on the checkbox only the result of that document are shown.