gpt4 book ai didi

elasticsearch - 在Elasticsearch中搜索字段

转载 作者:行者123 更新时间:2023-12-02 23:19:55 24 4
gpt4 key购买 nike

我有一个类似于此的JSON文档

{"type":"line","line_id":89522,"play_name":"Taming of the Shrew","speech_number":19,"line_number":"2.1.58","speaker":"PETRUCHIO","text_entry":"To instruct her fully in those sciences,"}
{"index":{"_index":"shakespeare","_id":89522}}
{"type":"line","line_id":89523,"play_name":"Taming of the Shrew","speech_number":19,"line_number":"2.1.59","speaker":"PETRUCHIO","text_entry":"Whereof I know she is not ignorant:"}
{"index":{"_index":"shakespeare","_id":89523}}
{"type":"line","line_id":89524,"play_name":"Taming Day","speech_number":19,"line_number":"2.1.60","speaker":"PETRUCHIO","text_entry":"Accept of him, or else you do me wrong:"}
{"index":{"_index":"shakespeare","_id":89524}}

我正在尝试对play_name进行搜索,只要play_name包含“Taming”,它将返回。

我的查询是这样的
GET /shakespeare/doc/_search
{
"query":{
"match":{"play_name":"Taming"}
}

}

但是,问题是它不会返回play_name包含Taming的所有结果。我阅读了文档,看来应该可以使用。因此,谁能告诉大众我在做什么错?

PS:这是我的映射设置
{
"shakespeare": {
"mappings": {
"doc": {
"properties": {
"line_id": {
"type": "integer"
},
"line_number": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"play_name": {
"type": "keyword"
},
"speaker": {
"type": "keyword"
},
"speech_number": {
"type": "integer"
},
"text_entry": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}

最佳答案

编辑

尝试这样:

"query": {
"wildcard" : {
"play_name":"*Taming*"
}
}

关于elasticsearch - 在Elasticsearch中搜索字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50782918/

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