- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
没有太多背景,这是我的问题:
要在 C# 中使用 .NET SDK 创建新的 Azure 搜索索引(使用文档中提供的酒店示例),我的代码如下所示:
public class Hotel
{
[System.ComponentModel.DataAnnotations.Key]
[IsFilterable]
public string HotelId { get; set; }
[IsFilterable, IsSortable, IsFacetable]
public double? BaseRate { get; set; }
[IsSearchable]
public string Description { get; set; }
[IsSearchable]
[Analyzer(AnalyzerName.AsString.FrLucene)]
[JsonProperty("description_fr")]
public string DescriptionFr { get; set; }
[IsSearchable, IsFilterable, IsSortable]
public string HotelName { get; set; }
[IsSearchable, IsFilterable, IsSortable, IsFacetable]
public string Category { get; set; }
[IsSearchable, IsFilterable, IsFacetable]
public string[] Tags { get; set; }
[IsFilterable, IsFacetable]
public bool? ParkingIncluded { get; set; }
[IsFilterable, IsFacetable]
public bool? SmokingAllowed { get; set; }
[IsFilterable, IsSortable, IsFacetable]
public DateTimeOffset? LastRenovationDate { get; set; }
[IsFilterable, IsSortable, IsFacetable]
public int? Rating { get; set; }
[IsFilterable, IsSortable]
public GeographyPoint Location { get; set; }
}
private static void CreateHotelsIndex(ISearchServiceClient serviceClient)
{
var definition = new Index
{
Name = "hotels",
Fields = FieldBuilder.BuildForType<Hotel>()
};
serviceClient.Indexes.Create(definition);
}
这很好用。
问题与使用 .NET SDK 进行搜索有关。前缀搜索工作正常
var results = indexClient.Documents.Search<Hotel>("cheap*");
将返回所有包含以“便宜”开头的字符串的文档,但我需要一种 string.Contains() 类型的功能,或者至少是后缀搜索。我正在尝试做类似的事情
var results = indexClient.Documents.Search<Hotel>("*heap*");
获取任意位置包含字符串“heap”的所有结果。
我知道有一些方法可以使用自定义分析器来执行此操作,但这些分析器只能通过 Azure 搜索 REST API 创建和应用,并且只能在创建索引时使用。这使得我上面提供的几乎所有内容都无法使用,因为我必须通过 Postman 在 JSON 中定义我的“酒店”索引、字段和分析器,而 SDK 实际上只对查询有用。这也意味着我需要在我创建的每个索引中重复定义相同的自定义分析器,因为 Azure 搜索似乎不支持全局分析器定义。
所以这里的问题是:有没有一种方法可以在 C# 中定义自定义分析器,我可以在创建索引时引用并应用于我的索引?或者,真的,是否有仅使用 .NET SDK 即可获得完整通配符支持的简单方法?
最佳答案
你可以这样做:
private static void CreateHotelsIndex(ISearchServiceClient serviceClient)
{
var definition = new Index
{
Name = "hotels",
Fields = FieldBuilder.BuildForType<Hotel>(),
Analyzers = new[]
{
new CustomAnalyzer
{
Name = "my_analyzer",
Tokenizer = TokenizerName.Standard,
TokenFilters = new[]
{
TokenFilterName.Lowercase,
TokenFilterName.AsciiFolding,
TokenFilterName.Phonetic
}
}
}
};
serviceClient.Indexes.Create(definition);
}
...然后在文档定义中引用自定义分析器:
[IsSearchable, IsFilterable, IsSortable, Analyzer("my_analyzer")]
public string HotelName { get; set; }
参见 Custom analyzers in Azure Search API 单元测试的博客文章和示例 CustomAnalyzerTests获取更多信息。
关于c# - Azure 搜索 .NET SDK 自定义分析器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48408000/
我最近开始使用 Scala 编程。我正在寻找免费的 Scala 分析器。从该语言的官方网站阅读后,我找到了 YourKit ,但该程序不是免费的。 谷歌搜索“scala profiler”没有给我任何
是否有一个程序可以让我获得有关脚本的详细信息:具体来说,我希望能够跟踪其内存占用情况并查看内存中有多少对象。 Firebug 有一个分析器,似乎可以提供计时信息,但我对内存管理更感兴趣。 最佳答案 G
Erlang 有没有好的代码分析器/分析器?我需要一些可以为我的代码构建调用图的东西。 最佳答案 对于静态代码分析,您有 Xref和 Dialyzer ,对于分析,您可以使用 cprof、fprof
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
什么是“self”和“total”列? “总计”列加起来不等于 100%(高得多),看起来像 self 一样。我怀疑 self 是非累积的,而 total 是。因此,如果 methodA 调用 met
在 Perl 中,有一个非常好的分析器,称为 NYTProf。 在其报告中包含 flame graph ,这样就很容易找到程序的瓶颈 是否有一个等效的 java profiler 可以生成相同的报告?
我想知道是否有办法在c++程序中查看特定部分的调用路径。我在开源代码中工作,其中包含许多库。我尝试按照最终在模板中的路径中的代码进行操作。那么,是否有这样的库或分析器来显示代码特定部分的调用路径? 谢
我正在寻找支持每个请求分析统计的分析器,最好是沿着程序流(而不是通常的线程调用堆栈)。所以基本上是每个请求的探查器调用堆栈 + 顺序调用 View ,如下所示: doGet
如何让 symfony profiler 在 phpstorm 中工作?它应该在状态栏中,但是当我打开那个窗口时,它总是说:“这里什么都没有”。缓存目录在配置中正确定义,symfony 插件本身工作正
人们在 Unix 中用来解析/分析日志文件的流行工具是什么?进行计数,查找唯一性,选择/复制具有特定模式的特定行。请提供一些工具或一些关键字。因为我相信以前肯定有类似的问题,但我对关键字一无所知。谢谢
我设置了一个过滤器来计算执行的查询数量,并在超过某个限制时将一些内容写入我的数据库。 它在我的开发环境中运行良好,但是当我在生产环境中测试它时,我的数据库不再返回分析器。我认为这是一个为开发环境启用数
你找到这样的工具并成功使用了吗? 最佳答案 我也在寻找 AS 的分析器,但我想要一个与 FlashDevelop 和 Flex SDK 配合使用的免费软件/开源解决方案。我没有找到。所以我写了一个简单
我需要扩展 SonarQube,以便我可以向其中添加新的分析器。我尝试使用 xpath 为 java 文件添加新规则。我想知道如何在 SonarQube 中添加新语言的代码分析器,例如对于 .meta
我可以在C#(嵌套)中使用elasticsearch 2.3.0版本 我想将分析与索引一起使用, 但是索引设置不会改变,我也不知道为什么。 这是我的代码: private void b
我有一个正在wireshark中查看的自定义协议(protocol)。我认为如果wireshark可以帮我剖析它,这样我就不必解码十六进制了,这会很有用。尽管我在程序日志中执行此操作,但wiresha
我正在考虑使用 Elasticsearch 来提供我们网站的搜索功能。 我一直在试验它,但无法启用 Porterstem 分析器(以便搜索战斗匹配战斗和战斗)。 这是我输入的摘要。 curl
我正在尝试运行一个基于java的java分析器来找出我的专用机器上的java应用程序的资源消耗情况。我尝试使用的分析器称为 Warmroast。 运行时出现以下错误。 java -jar warmro
我没有从我的分析器获得预期结果,并且想测试标记化过程。 此问题的答案:How to use a Lucene Analyzer to tokenize a String? List result =
我在 Lucene 中有特殊的分析需求,但我想继续使用 StandardAnalyzer 机制的部分内容。 特别是,我想要字符串 “-苹果--胡萝卜-番茄?” 被标记为: “-苹果-”2.“-胡萝卜-
有什么好的 JSF 分析器推荐吗? 我正在使用 Tomcat 6 JSF2、 hibernate 和 Spring 最佳答案 如果您使用的是 Eclipse 或 Netbeans 之类的 IDE,那么
我是一名优秀的程序员,十分优秀!