Elasticsearch Nest full text search with filters

I have created a search descriptor in order to be able to filter some data from elasticsearch, it seems that all my tests that excercise the filters functionality pass but they fail for the full text search.

I have tried all variations and am lost as to why this is happening.

the poco:

[ElasticsearchType(Name = "restaurant")]
public class RestaurantSearchItem
{
    public const string IndexName = "restaurants";

    [Keyword]
    public string Id { get; set; }

    [Text]
    public string Name { get; set; }

    public decimal Rating { get; set; }

    public int ReviewCount { get; set; }

    public string UrlName { get; set; }

    [Keyword]
    public string CountryCode { get; set; }

    [GeoPoint]
    public Geolocation Location { get; set; }

    [Keyword]
    public string[] CuisineIds { get; set; }

    [Keyword]
    public string[] StyleIds { get; set; }

    public Image[] Images { get; set; }
}

the mapping:

await _elasticClient.CreateIndexAsync(
                RestaurantSearchItem.IndexName,
                i => i.Mappings(ms => ms.Map<RestaurantSearchItem>(m => m.AutoMap())), cancellation);

the descriptor:

var filters = new List<Func<QueryContainerDescriptor<RestaurantSearchItem>, QueryContainer>>();

        if (request.Query.CuisineIds?.Any() == true)
        {
            filters.Add(fq => fq.Terms(t => t.Field(f => f.CuisineIds).Terms(request.Query.CuisineIds)));
        }

        if (request.Query.StyleIds?.Any() == true)
        {
            filters.Add(fq => fq.Terms(t => t.Field(f => f.StyleIds).Terms(request.Query.StyleIds)));
        }

        return descriptor => descriptor
            .Query(q => q
                .Bool(b => b
                    .Must(m => m 		  	
                        .MultiMatch(mp => mp 	
                            .Query(request.Query.FreeText)
                            .Fields(f => f
                                .Fields(r => r.Name))))
                    .Filter(f => f 		   	
                        .Bool(b1 => b1
                            .Must(filters)))))
            .Sort(o => o.Ascending(r => r.Id))
            .From(request.Offset)
            .Size(request.PageSize);
    }

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.