Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net Elasticsearch嵌套带过滤器的全文搜索_.net_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Nest - Fatal编程技术网 elasticsearch,nest,.net,elasticsearch,Nest" /> elasticsearch,nest,.net,elasticsearch,Nest" />

.net Elasticsearch嵌套带过滤器的全文搜索

.net Elasticsearch嵌套带过滤器的全文搜索,.net,elasticsearch,nest,.net,elasticsearch,Nest,我已经创建了一个搜索描述符,以便能够从elasticsearch中过滤一些数据,似乎我所有执行过滤器功能的测试都通过了,但全文搜索失败 我尝试了所有的变化,但我不知道为什么会发生这种情况 poco: [ElasticsearchType(Name = "restaurant")] public class RestaurantSearchItem { public const string IndexName = "restaurants"; [Keyword] pub

我已经创建了一个搜索描述符,以便能够从elasticsearch中过滤一些数据,似乎我所有执行过滤器功能的测试都通过了,但全文搜索失败

我尝试了所有的变化,但我不知道为什么会发生这种情况

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; }
}
映射:

await _elasticClient.CreateIndexAsync(
                RestaurantSearchItem.IndexName,
                i => i.Mappings(ms => ms.Map<RestaurantSearchItem>(m => m.AutoMap())), cancellation);
wait\u elasticClient.CreateIndexAsync(
RestaurantArchitem.IndexName,
i=>i.Mappings(ms=>ms.Map(m=>m.AutoMap()),取消);
描述符:

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);
    }
var过滤器=新列表();
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));
}
返回描述符=>描述符
.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(过滤器((())))
.Sort(o=>o.升序(r=>r.Id))
.从(请求.抵销)
.Size(请求页面大小);
}

如果不知道您的数据和查询,就无法回答此问题。查看Explain API以了解给定文档与给定查询不匹配的原因: