Question

I am working on search functionality for a website designed through umbraco. I am using Examine to fetch the search results. Here is my code:

 var Searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
            var searchCriteria = Searcher.CreateSearchCriteria(BooleanOperation.Or);
            var query = searchCriteria.Field("tags", searchTerm.Fuzzy(0.5f)).Compile();
            var searchResults = Searcher.Search(query);

With this method i can only get the nodes in which the search term belongs.But I want to directly fetch the whole value from the property.

I want to know what is the fastest way to fetch all the values from the same property in all the nodes.

Was it helpful?

Solution

I have finally managed to get the values directly from the property.This is the code I have used:

    List<string> nodesList = new List<string>();
    var Searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
    var searchCriteria = Searcher.CreateSearchCriteria(BooleanOperation.Or);
    var query = searchCriteria.Field("tags", queryString.Fuzzy(0.5f)).Compile();
    var searchResults = Searcher.Search(query);
    foreach (var item in searchResults)
    {
        string paths = ((Examine.SearchResult)item).Fields["tags"];
        nodesList.Add(paths); 
    }

using ((Examine.SearchResult)item).Fields["tags"] gets the property value directly.

OTHER TIPS

If you want to costumize your search you need to define a new index set with the properties that you actually want to search on the /config/examineIndex.config file.

Quite well explained in this post.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top