2016-06-20 72 views
1

当我运行这个搜索,我回来我期待记录:匹配的特定领域,但是,_all(ES 1.7)不匹配

POST users/user/_search 
{"query":{"match":{"name":"smi"}}} 

产量:

{ 
    "took": 3, 
    "timed_out": false, 
    "_shards": { "total": 5, "successful": 5, "failed": 0 }, 
    "hits": { 
    "total": 1, 
    "max_score": 0.8838835, 
    "hits": [ 
     { 
     "_index": "users", 
     "_type": "user", 
     "_id": "648398826796745835", 
     "_score": 0.8838835, 
     "_source": { 
      "email": "[email protected]", 
      "name": "Jon Smith", 
      "username": "jonsmith", 
      "first_name": "Jon", 
      "last_name": "Smith", 
      "image_url": "blahblahblah" 
     } 
     } 
    ] 
    } 
} 

然而,当我运行,我期望的工作以及类似的搜索,我得到什么:

POST users/user/_search 
{"query":{"match":{"_all":"smi"}}} 

产量:

{ 
    "took": 1, 
    "timed_out": false, 
    "_shards": { 
    "total": 5, 
    "successful": 5, 
    "failed": 0 
    }, 
    "hits": { 
    "total": 0, 
    "max_score": null, 
    "hits": [] 
    } 
} 

的映射是非常简单的:

GET users/_mapping/user 

{ 
    "users": { 
    "mappings": { 
     "user": { 
     "properties": { 
      "email": { "type": "string", "analyzer": "our_email" }, 
      "email_username": { "type": "string", "analyzer": "email_username" }, 
      "first_name": { "type": "string", "analyzer": "our_name" }, 
      "image_url": { "type": "string", "index": "not_analyzed" }, 
      "last_name": { "type": "string", "analyzer": "our_name" }, 
      "name": { "type": "string", "analyzer": "our_name" }, 
      "username": { "type": "string", "analyzer": "our_name" } 
     } 
     } 
    } 
    } 
} 

our_name分析仪中实现这样的,虽然我不能找到1.7 API的方式来做分析仪配置一个GET:

{ 
    "analysis": { 
    "analyzer": { 
     "our_name": { 
     "filter": [ 
      "lowercase", 
      "word_delimiter", 
      "our_edgeNgram25" 
     ], 
     "tokenizer": "standard" 
     } 
    }, 
    "filter": { 
     "our_edgeNgram25": { "max_gram": 5, "min_gram": 2, "type": "edgeNGram" }, 
     "our_email_filter": { 
     "patterns": [ "(.+)@(.+)" ], 
     "type": "pattern_capture" 
     } 
    } 
    } 
} 

运行在user.name现场演示分析让我觉得这应该匹配的是:

GET users/_analyze?analyzer=our_name&text=jon%20smith 
{ 
    "tokens": [ 
    { 
     "token": "jo", 
     "start_offset": 0, 
     "end_offset": 3, 
     "type": "word", 
     "position": 1 
    }, 
    { 
     "token": "jon", 
     "start_offset": 0, 
     "end_offset": 3, 
     "type": "word", 
     "position": 1 
    }, 
    { 
     "token": "sm", 
     "start_offset": 4, 
     "end_offset": 9, 
     "type": "word", 
     "position": 2 
    }, 
    { 
     "token": "smi", 
     "start_offset": 4, 
     "end_offset": 9, 
     "type": "word", 
     "position": 2 
    }, 
    { 
     "token": "smit", 
     "start_offset": 4, 
     "end_offset": 9, 
     "type": "word", 
     "position": 2 
    }, 
    { 
     "token": "smith", 
     "start_offset": 4, 
     "end_offset": 9, 
     "type": "word", 
     "position": 2 
    } 
    ] 
} 

建议表示感谢,谢谢。

回答

1

_all默认使用标准分析仪,所以你不能找到子字符串,在映射中指定你的分析仪为_all

+0

非常感谢!不幸的是,这不是_all上的文档的一部分,但很高兴知道。 – voxobscuro

相关问题