requestError:requestError(400,search_phase_execution_exception未能在elasticsearch中为输入字符串创建查询
下面是我的字典
abc = [
{'id':"1", 'name': 'cristiano ronaldo', 'description': '[email protected]'},
{'id':"2", 'name': 'lionel messi', 'description': '[email protected]'},
{'id':"3", 'name': 'Lionel Jr', 'description': '[email protected]'}
]
将播放器摄入
for i in abc:
es.index(index="players", body=i, id=i['id'])
下面的Elasticsearch,是DSL查询
resp = es.search(index="players",body={
"query": {
"query_string": {
"fields": ["id^12","description^2", "name^2"],
"query": "[email protected]"
}
}})
resp
第1期: 如果
“字段”:[“ ID^12”,“ Description^2”,“ name^2”]
,那么我正在获取错误request> requesterror:requestError(400,'search_phase_execution_exection_exception','',''无法创建查询:输入字符串:“
-
第2期: 如果我的字段是
[“ Descript^2”,“ Name^2”]
我希望一个文档包含[email  pretained]
,但返回所有3个文档
:返回所有SAGAR我的设置ID的评论。映射在下面。 第1期已解决
{'players': {'mappings': {'properties': {'description': {'type': 'text',
'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}},
'id': {'type': 'text',
'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}},
'name': {'type': 'text',
'fields': {'keyword': {'type': 'keyword', 'ignore_above': 256}}}}}}}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
f89a8a99829194b89e919e919e99e999d69b9795795
ID
字段定义为Integer
或flot
字段类型(其他text
字段类型)。您需要在查询中提供“ Lenient”:True
,并且不会返回任何例外。之所以发生,是因为您正在
文本
搜索时应用默认标准
分析仪的字段类型。因此,当您搜索
巴西
和fifa.com
。在这里,fifa.com
在您的所有3个文档中都匹配,因此结果返回。要解决此问题,您可以使用Description.keyword
字段。下面的查询将解决您的两个问题:
更新:
如果要搜索
fifa
,则基于注释,然后您需要提供Description
作为字段但是,当您搜索您需要以双引号提供它以进行精确匹配。请参阅下面的示例:
Above issue you are getting because your
id
field is define asinteger
orflot
type of field (other thentext
type of field). You need to provide"lenient": true
in your query and it will not return any exception.Above issue is happening because you are searching on
text
type of field which applied defaultstandard
analyzer when you do search.So when you search
[email protected]
then it will create two tokenbrazil
andfifa.com
. Here,fifa.com
is matching in your all 3 documents so it is returning in result. To resolved this issue, you can usedescription.keyword
field.Below query will resolved your both issue:
Updated:
Based on comment if you want to search
fifa
as well then you need to providedescription
as field but when you search[email protected]
then you need to provide it in double quotes for exact match. Please see below example: