0
votes

I want to do a full text search on HTML files in the blob storage.I have created an azure search service, added data source to the service and created index and indexer through Azure portal.

I tested the Azure search service in the portal using Search explorer.It works fine.

But I wanted to display the search results in Console window using c# code instead of testing on search explorer.

Do I have to write a POJO class for DataSource even if data source for the service is created through Azure Portal

Followig is the code snippet

SearchServiceClient serviceClient = new SearchServiceClient(searchServiceName, new SearchCredentials(searchServiceKey));

ISearchIndexClient indexClient = serviceClient.Indexes.GetClient(indexName);

DocumentSearchResult searchResults = indexClient.Documents.Search(searchText);

I want to convert search results object to readable text and display in Console window. I tried Base64Decode method but no expected result. Please help me through this issue.

Thanks in advance!!!

1
Well, what did you get? HTML?Lasse V. Karlsen
I am getting searchResults objectcode-geek
DocumentSearchResult .Results? Looking at it here... docs.microsoft.com/en-us/dotnet/api/…Marko
I would like to know how to extract the search result content from search result objectcode-geek

1 Answers

1
votes

The Document you receive will be JSON that contains each of the fields of the search document.

Your question is not clear as to whether you want to display the original HTML or the text extracted from the HTML document.

If you only care about the text (without HTML formatting), take a look at the content field. It will have the information that you need. Make sure the content field is retrievable in your search index so you get it as part of the result.

If you want the document with actual HTML formatting, usually that is not part of the result document as that is not indexed. In these cases, usually people add the metadata_storage_path to the index make sure that it is retrievable. Then using that path you can just go and read the original file from blob storage. If you used the metadata_storage_path field as the key of your index, and encoded it using base64, make sure to decode the path.