0
我正面临使用通配符的问题。每当我试图找到使用通配符的数据,它返回一个错误无法为ElasticSearch写入通配符查询?
数据集看起来像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": "[email protected]",
"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的新手,所以这一点并没有超出我的想象。再次感谢。 –
太棒了,很高兴帮助! – Val
在同一片段中再增加一个查询......我们可以在文档中为Long数据类型的字段编写通配符查询吗? {“通配符”:{“age”:2 *}} 还是有没有其他的方式来实现这一点,而不使用通配符...? –