我有收藏用户,所有文档的结构如下:
{
"username": "de",
"userId": 123456,
"followers":[
{
"userId":123,
"username": "bc",
},
{
"userId": 456,
"username": "ac",
}
}
还有更多文件:
{
"username": "a",
"userId": 123456,
"followers":[
{
"userId": 456,
"username": "ab",
}
}
我想索引“用户名”字段(父级,不在关注者中)。我喜欢以下:
curl -XPUT http://localhost:9200/users -d '
{
"mappings":{
"multisearch":{
"properties":{
"username":{
"type":"string",
"analyzer":"partial_name",
"search_analyzer":"partial_name",
"index_analyzer":"partial_name"
}
}
}
},
"settings":{
"analysis":{
"filter":{
"name_ngrams":{
"side":"front",
"max_gram":20,
"min_gram":2,
"type":"NGram"
}
},
"analyzer":{
"full_name":{
"filter":[
"standard",
"lowercase",
"asciifolding"
],
"type":"custom",
"tokenizer":"standard"
},
"partial_name":{
"filter":[
"standard",
"lowercase",
"asciifolding",
"name_ngrams"
],
"type":"custom",
"tokenizer":"standard"
}
}
}
}
}'
我将新的 mongodb 河添加到 elasticsearch:
curl -XPUT 'localhost:9200/_river/mongodb/_meta' -d '{
"type": "mongodb",
"mongodb": {
"servers": [
{"host": "Konoha", "port": 27018},
{"host": "Konoha", "port": 27027}
],
"db": "mydatabase",
"collection": "users",
"options": {
"secondary_read_preference": true,
"drop_collection": true
},
"gridfs": false
},
"index": {
"name": "users",
"type": "multisearch"
}
}'
现在我尝试使用关键字“manh”进行搜索,我在浏览器中运行:
http://localhost:9200/users/multisearch/_search?pretty=true&q=username:abc
结果是我上面描述的两个文件。我认为 ElasticSearch 还会在关注者字段中索引字段用户名吗?
我只想要行有用户名=abc(父)
你能帮我只索引父字段用户名吗?
感谢您的帮助:)
电影种子下载