Try our conversational search powered by Generative AI!

Getting boolean facet results through Optimizely Search



I need to get the Boolean values of a boolean property of content as as facet results.

However, instead of getting "true" or "false", I am getting the results as "T" and "F" (See the below sample code for more information).

        const string FieldName = "TextRight";
        const string FieldNameWithDataType = FieldName + "$$bool";

        IClient searchClient = GetSearchClient();
        var searchResults = _searchClient.Search<StandardPage>()

        searchResults = new Search<StandardPage, IQuery>(searchResults,
            context =>
                var facetRequest = new TermsFacetRequest(FieldName)
                    Field = FieldNameWithDataType

        var results = searchResults.GetContentResult();
        var facetResults = results.TermsFacetFor(x => x.TextRight);
        Console.WriteLine(facetResults.Terms.First().Term); // "F"
        Console.WriteLine(facetResults.Terms.Last().Term); // "T"

Note: I do not like to map these "T" and "F" values to "true" and "false" later after fetching the results. Because when I add other facets, if those facets contain "T" or "F" values, then they will be misunderstood as Boolean values. And I do not like to create an additional string property for the content that mirrors the boolean value and use it for faceting.

May 15, 2023 12:05
- May 15, 2023 12:21
The reason that I do not like to map string value "T" and "F" to "true" or "false" is that when I add other fields (Non boolean) for faceting, I do not like the facet results to be recognised as "true" for "T" and "false" for "F".

Optimizely support confirmed that this is not supported by Optimizely Find as of now. It returns "T" and "F" because of the Elasticsearch version Optimizely uses as of now.
So for the moment, we have to rely on a workaround for this.

May 25, 2023 12:59
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.