【发布时间】:2018-12-08 07:02:04
【问题描述】:
我有一个名为 users 的索引
当我使用以下查询向http://localhost:9200/users/_search?pretty=true 发出请求时:
curl -X GET "localhost:9200/users/_search?pretty=true" -H 'Content-Type: application/json' -d'
{
"query": {
"query_string": {
"query" : "firstName: Daulet"
}
}
}'
查询返回两个具有以下名称的用户:
firstName: Daulet
firstName: Daulet Nurlanuly
如何使查询字符串查询返回带有firstName: Daulet 的文档?
我查看了 Elasticsearch 使用 Apache Lucene 的请求语法,对于严格搜索,我需要通过将请求括在引号中来执行以下操作:
firstName: "Daulet"
但是已经用引号括起来了
如何仅使用查询字符串查询来做到这一点?
** 更新 **
我在http://localhost:9200/users 发出 GET 请求时得到的响应:
{
"users": {
"aliases": {},
"mappings": {
"userentity": {
"properties": {
"firstName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"id": {
"type": "long"
},
"language": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"lastName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
},
"settings": {
"index": {
"refresh_interval": "1s",
"number_of_shards": "5",
"provided_name": "users",
"creation_date": "1530245236170",
"store": {
"type": "fs"
},
"number_of_replicas": "1",
"uuid": "IlE1Ynv2Q462LBttptVaTg",
"version": {
"created": "5060999"
}
}
}
}
}
【问题讨论】:
标签: apache elasticsearch lucene