2013-10-30 56 views
0

部分搜索這是我的位置集合中的mongodb:Elasticsearch和MongoDB,不工作

{ "_id" : ObjectId("5270d36f28f31fd8fa016441"), "stateName" : "A5", "cityName" : "ABCNEW2" } 
{ "_id" : ObjectId("5270d37328f31fd8fa016442"), "stateName" : "A5", "cityName" : "ABC" } 
{ "_id" : ObjectId("5270d37b28f31fd8fa016443"), "stateName" : "65", "cityName" : "ABCRW" } 

我使用彈性搜索創建一個索引:

POST /bwitter 
{"index": 
    { "number_of_shards": 1, 
    "analysis": { 
     "filter": { 
        "mynGram" : {"type": "nGram", "min_gram": 2, "max_gram": 10} 
       }, 
     "analyzer": { "a1" : { 
        "type":"custom", 
        "tokenizer": "standard", 
        "filter": ["lowercase", "mynGram"] 
        } 
        } 
    } 
    } 
} 

我使用彈性搜索創建一個映射:

PUT /bwitter/bweet/_mapping 
{ 
    "bweet" : { 
     "index_analyzer" : "a1", 
     "search_analyzer" : "standard", 
     "properties" : { 
      "stateName": {"type":"string", "analyzer":"standard"}, 
      "cityName" : {"type" : "string" } 
     } 
    } 

}

創建河流如下:

PUT /_river/mongodb/_meta 
{ 
    "type": "mongodb", 
    "mongodb": { 
     "db": "rakeshdb", 
     "collection": "locations" 
    }, 
    "index": { 
     "name": "locations", 
     "type": "bweet" 
    } 
} 

如果,我查詢GET /locations/_search?q=ABC,我只得到一個記錄(全詞搜索正在發生的事情,沒有發生對部分字)

我幾乎花了整整一天這但不能解決這個問題。我哪裏錯了?

回答

1

我想這應該是:

PUT /_river/mongodb/_meta 
{ 
    "type": "mongodb", 
    "mongodb": { 
     "db": "rakeshdb", 
     "collection": "locations" 
    }, 
    "index": { 
     "name": "bwitter", 
     "type": "bweet" 
    } 
} 
+0

由於一噸!它的工作現在很好。使用的查詢:GET/bwitter/_search?q = ABC –