gpt4 book ai didi

java - Elasticsearch 和 mongodb,部分搜索不起作用

转载 作者:行者123 更新时间:2023-12-01 13:54:42 25 4
gpt4 key购买 nike

这是我在 mongodb 中的位置集合:

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

我使用 Elasticsearch 创建了一个索引:

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"]
}
}
}
}
}

我使用 Elasticsearch 创建了一个映射:

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,我只得到一条记录(正在发生全字搜索,而对于部分字则不会发生)

我几乎花了一整天的时间但无法解决这个问题。我哪里错了?

最佳答案

我想应该是:

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

关于java - Elasticsearch 和 mongodb,部分搜索不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19681129/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com