Epinova / Epinova.Elasticsearch

A search-plugin for Episerver CMS and Commerce
MIT License
29 stars 20 forks source link

Filtering on PageTypeName not working #18

Closed bjornamr closed 5 years ago

bjornamr commented 6 years ago

We have been trying to filter on different pagetypes with no luck.

What we do is create the query like this:

            var query = _elasticSearchService
                    .Search<PageData>(model.SearchedQuery)
                    .Highlight()
                    .Language(culture);

and filter like this:

query = query.Filter(p => p.PageTypeName, "ReportPage"); The ReportPage class inherits from SitePageDate. It seems to work When we try to filter like this we always get zero results.

We use query.getContentResults to get the results. We are able to see the PageTypeName from the results in result.Hits where we can look at Content.PageTypeName for each hit.

We have also tested to see if the filter in general works, and it seems like it works to filter on for example name like this: query = query.Filter(p => p.Name, "Testreportname");

Do you guys have any Idea what the root of the problem could be?

paalm commented 5 years ago

All the ignored properties can be available if you add the property at Initialization like this:

Epinova.ElasticSearch.Core.Conventions.Indexing.Instance.ForType<PageData>().IncludeField(x => x.PageTypeName)