gpt4 book ai didi

c# - Elasticsearch.net NEST无法过滤URL

转载 作者:行者123 更新时间:2023-12-02 23:03:35 30 4
gpt4 key购买 nike

我正在运行一个基本上创建URL缩短器的应用程序,当我设置大小写的“shorurl”时,无法获得查询或过滤器来查找它。但是,对于其他更简单的字段,它也可以正常工作。我尝试对它做小写,但不确定如何匹配。

这是字段定义:

       [ElasticProperty(Name = "shorturl", IncludeInAll = true)]
public string ShortUrl { get; set; }

这是一个例子:
        string url = "http://test.com/JjdWtPoV";

FilterContainer filter = new FilterContainer();
filter = Filter<Data>.Term("shorturl", url);

var results = this.Client.Search<Data>(s => s
.Filter(filter)
);

QueryContainer q = new QueryContainer();
q = Query<Data>.Term("shorturl", url);

results = this.Client.Search<Data>(s => s
.Query(q)
);

results = this.Client.Search<Data>(s => s
.Query(f => f.Term(p=> p.ShortUrl, url))
);

我应该注意以下是我正在使用的版本:
        <?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Elasticsearch.Net" version="1.3.1" targetFramework="net45" />
<package id="NEST" version="1.3.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.1" targetFramework="net45" />
</packages>

找到答案
需要确保字符串设置为“NOT ANALYZED”
        [ElasticProperty(Name = "shorturl", IncludeInAll = true,                          
Index=FieldIndexOption.NotAnalyzed)]
public string ShortUrl { get; set; }

最佳答案

   [ElasticProperty(Name = "shorturl", IncludeInAll = true,                          
Index=FieldIndexOption.NotAnalyzed)]
public string ShortUrl { get; set; }

关于c# - Elasticsearch.net NEST无法过滤URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27930361/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com