gpt4 book ai didi

elasticsearch - 查询时间上的Latenise token

转载 作者:行者123 更新时间:2023-12-02 22:30:36 26 4
gpt4 key购买 nike

我需要对查询(或过滤)时使用的查询 token 进行后期处理。我可以在应用程序级别执行此操作,但我想知道Elasticsearch是否提供了开箱即用的解决方案。

我正在使用ES 1.7.5(作为服务)

最佳答案

默认情况下,elasticsearch将在索引时间和查询时间使用相同的分析器,但是可以指定 search_analyzer ,它仅在查询时使用。

让我们看下面的例子:

# First we define an analyzer which will fold non ascii characters called `latinize`.
PUT books
{
"settings": {
"analysis": {
"analyzer": {
"latinize": {
"tokenizer": "standard",
"filter": ["asciifolding"]
}
}
}
},
"mappings": {
"book": {
"properties": {
"name": {
"type": "string",
"analyzer": "standard", # We use the standard analyzer at index time.
"search_analyzer": "latinize" # But we use the latinize analyzer at query time.
}
}
}
}
}

# Now let's create a document and search for it with a non latinized string.
POST books/book
{
"name": "aaoaao"
}

POST books/_search
{
"query": {
"match": {
"name": "ääöääö"
}
}
}

和ba!有我们的文件。
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.30685282,
"hits": [
{
"_index": "books",
"_type": "book",
"_id": "AVkIXdNyDpmDHTvI6Cp1",
"_score": 0.30685282,
"_source": {
"name": "aaoaao"
}
}
]
}
}

关于elasticsearch - 查询时间上的Latenise token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41187402/

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