如何在天蓝色搜索中搜索带有中间破折号的术语? [英] How to search a term with a middle dash in azure search?

查看:88
本文介绍了如何在天蓝色搜索中搜索带有中间破折号的术语?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习使用天蓝色搜索,但找不到在ItemId字段中带有中间破折号的搜索词的方法,而不在乎搜索该词是在开头还是中间.

I'm learning to use azure search and I dont find a way to search a term with a middle dash into the ItemId field, doesn't care if the term to search it's at the beginning or at the middle.

我的索引中包含这些字段,其中有数据

I have these fields with data in my index

+-----+--------------------+-------------+
| Cat |       ItemId       | Description |
+-----+--------------------+-------------+
| 100 |  400800-1100103U   | desc item 1 |
| 100 |  400800-11001066   | desc item 2 |
| 100 |  400800-11001068   | desc item 3 |
| 101 |  400800-110010F6   | desc item 4 |
+-----+--------------------+-------------+

这是我的索引字段配置:

This is my index field configuration:

+-------------+-------------+-----------+-----------+-----------+------------+
| Field Name  | Retrievable | Filerable |  Sortable | Facetable | Searchable |
+-------------+-------------+-----------+-----------+-----------+------------+
| Cat         |    OK       |    OK     |    OK     |    OK     |    X       |
| ItemId      |    OK       |    OK     |    OK     |    OK     |    OK      |
| Description |    OK       |           |           |           |            |
+-------------+-------------+-----------+-----------+-----------+------------+

这是我对ItemId字段的自定义分析器,即使有中间的破折号也仅生成一个令牌.

And this is my custom analyzer to the field ItemId to generate just one token even if has a middle dash.

{
  "@odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
  "name": "keyword_lowercase",
  "tokenizer": "keyword_v2",
  "tokenFilters": [
    "lowercase"
  ],
  "charFilters": []
}

如果我使用以下查询进行搜索:$select=RowKey&search=400800-1100*

If I search with this query: $select=RowKey&search=400800-1100*

我得到这些结果:

  • 400800-1100103U
  • 400800-11001066
  • 400800-11001068
  • 400800-110010F6

但是,如果我尝试使用这样的中间词进行搜索:$select=RowKey&search=RowKey:(00800-1100*)~

But if I try to search with a middle term like this: $select=RowKey&search=RowKey:(00800-1100*)~

我得到0条结果.

那么我如何在ItemId中搜索带有中间破折号的术语,而不在乎搜索的术语是在开头还是中间?

So how can I search a term with a middle dash into the ItemId, doesn't care if the term to search it's at the beginning or at the middle?

推荐答案

我相信模糊搜索或使用 Edge N-gram标记生成器进行反向令牌过滤器,具体取决于您的具体情况.

I believe that this post answers your question by using regular expression search but has some considerations. Alternatively you can consider using fuzzy search or use the Edge N-gram tokenizer with a reverse token filter depending on your specific scenario.

这篇关于如何在天蓝色搜索中搜索带有中间破折号的术语?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆