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 *}} 還是有沒有其他的方式來實現這一點,而不使用通配符...? –