【发布时间】:2017-02-06 05:43:33
【问题描述】:
我在使用通配符时遇到问题。每当我尝试使用通配符查找数据时,它都会返回错误
数据集在 ES 中如下所示:
"hits": {
"total": 1000,
"max_score": 1,
"hits": [
{
"_index": "accounts",
"_type": "data",
"_id": "25",
"_score": 1,
"_source": {
"account_number": 25,
"balance": 40540,
"firstname": "Virginia",
"lastname": "Ayala",
"age": 39,
"gender": "F",
"address": "171 Putnam Avenue",
"employer": "Filodyne",
"email": "virginiaayala@filodyne.com",
"city": "Nicholson",
"state": "PA"
}
}
我使用以下查询:
GET /_search
{
"query":{
"filtered" : {
"filter" : {
"bool" : {
"should" :
{
"match":{
"wildcard":{"lastname" : "Aya*" }
}
}
}
}
}
}
}
但它抛出以下错误:
{
"error": {
"root_cause": [
{
"type": "query_parsing_exception",
"reason": "[match] query does not support [lastname]",
"index": "accounts",
"line": 9,
"col": 25
}
我已经尝试在不使用匹配实例的情况下仅在查询中使用通配符,但我仍然无法获取数据。此处搜索成功,但没有返回数据。
没有匹配查询:
GET /_search
{
"query":{
"filtered" : {
"filter" : {
"bool" : {
"should" :
{
"wildcard":{"lastname" : "Aya*" }
}
}
}
}
}
}
请帮助我了解我应该如何设备查询。我也必须在 JAVA API 中使用这个查询字符串。因此,这方面的任何建议也会非常有帮助。
【问题讨论】:
标签: elasticsearch match wildcard