SridharVenkat
SridharVenkat

Reputation: 656

Azure Search Hierarchical Search Field

I am evaluating Azure Search for a project. The MSDN articles are having only Flattened schema structure. Below is an example scenario i am looking at.

The below is "Project" class having reference to List of "Question" class. And "Question" has it's own set of fields

public class Project
    {
        public Guid Id
        {
            get;
            set;
        }

        public string Owner
        {
            get;
            set;
        }

        public string Title
        {
            get;
            set;
        }

        public List<Question> QuestionList
        {
            get;
            set;
        }

        public bool Disable
        {
            get;
            set;
        }

}

public class Question
    {
        public Guid Id { get; set; }

        public string Title { get; set; }

        public string Description { get; set; }
    }

Below will be Index Schema for Project

Questions

The only point i see in MSDN relevant is the below paragraph and i can't make much sense of it

Levels in faceted navigation

As noted, there is no direct support for nesting facets in a hierarchy. Out of the box, faceted navigation only supports one level of filters. However, workarounds do exist. You can encode a hierarchical facet structure in a Collection(Edm.String) with one entry point per hierarchy. Implementing this workaround is beyond the scope of this article, but you can read about collections in OData by Example.

Upvotes: 2

Views: 1381

Answers (1)

Liam Cavanagh - MSFT
Liam Cavanagh - MSFT

Reputation: 1464

For your first question, Azure Search does not allow for hierarchical datatypes, and to search you would need to flatten the data as you did for the QuestionList field which you created as a Collection. If you were asking how to also filter results based on items in this Collection, you can do that using OData Expressions such as $filter=QuestionList/any(t: t eq 'Question1') (https://msdn.microsoft.com/en-us/library/azure/dn798921.aspx)

I think for your second question, you were interested searching only in "Title" or "Question", correct? For this, you can use the SearchFields parameter (https://msdn.microsoft.com/en-us/library/azure/dn798927.aspx).

Liam

Upvotes: 2

Related Questions