# Elasticsearch Nest full text search with filters

**URL:** https://discuss.elastic.co/t/elasticsearch-nest-full-text-search-with-filters/133912
**Category:** Elasticsearch
**Created:** [May 30, 2018, 4:05pm UTC](https://discuss.elastic.co/t/elasticsearch-nest-full-text-search-with-filters/133912 "2018-05-30T16:05:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ftaran](https://avatars.discourse-cdn.com/v4/letter/f/c77e96/32.png) [@ftaran](https://discuss.elastic.co/u/ftaran)
#### Post date: [May 30, 2018, 4:05pm UTC](https://discuss.elastic.co/t/elasticsearch-nest-full-text-search-with-filters/133912/1 "2018-05-30T16:05:00Z")

</div>

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);
    }
```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 27, 2018, 4:05pm UTC](https://discuss.elastic.co/t/elasticsearch-nest-full-text-search-with-filters/133912/2 "2018-06-27T16:05:05Z")

</div>

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