Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

"Bad Request" when using nested queries for facets

$
0
0

I'm having issues getting nested queries and facets to work on my Commerce catalog content types, specifically a product content and a variation content.

I'm running Find 11.1.0.3965, Commerce 9.8.1, and CMS 9.6.1.

The issue

When I try to get results from Find, I'm getting a "(400) Bad Request" (I've tried to cut out unnecessary error data):

SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; 
...
Parse Failure [Failed to parse source 
..."facets":{"MyNestedObjects.NestedObjectProperty":{"terms":{"field":"MyNestedObjects.NestedObjectProperty$$string"},"nested":"MyNestedObjects"},
...
Parse Failure [facet nested path [MyNestedObjects] not found]]; }

The code

Based on the documentation (http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/11/DotNET-Client-API/Searching/nested-queries/), I think I have everything configured and developed correctly.

This is done in an initialization module:

SearchClient.Instance.Conventions.NestedConventions.ForType().Add(content => content.MyNestedObjects);
SearchClient.Instance.Conventions.NestedConventions.ForType().Add(content => content.MyNestedObjects);

On the content types, I have the properties as such:

public IEnumerable MyNestedObjects
{
    get
    {
        var listOfNestedObjects = new List();
        ...
        return listOfNestedObjects;
    }
}

And I'm setting up the search and facets like this:

SearchClient.Instance.Search(Language.English)
    .For(someQueryText)
    .InFields(x => x.DisplayName)
    .InAllField()
    .TermsFacetFor(x => x.MyNestedObjects, x => x.NestedObjectProperty);
    .GetContentResult();

And an example of the indexed data on an instance of the content looks like:

..."MyNestedObjects$$nested": [
{"$type": "MyProject.Objects.NestedObject, MyProject","___types": ["MyProject.Objects.NestedObject","System.Object"
    ],"NestedObjectProperty$$string": "Some Value"
}]
...

I have also tried this all as a function call on the content types, making sure to IncludeField() the function call, but the result is the same.

So everything looks to be set up correctly, right? What gives?


Viewing all articles
Browse latest Browse all 6894

Trending Articles