Mongodb index parent field?

Hi everybody!

I have collection users, all document have structure like following:

{
"username": "manhnv",
"userId": 123456,
"followers":[
{
"userId":123,
"username": "datmoi",
},
{
"userId": 456,
"username": "hoangpheo",
}
}

And more documents:
{
"username": "hungga",
"userId": 123456,
"followers":[
{
"userId": 456,
"username": "manhnv",
}
}

I want to index "username" field (parent, not in followers). I do like
following:

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

And I add new mongodb river to 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"
}
}'

And now I try to search with keyword "manh", I run in browser:
http://localhost:9200/users/multisearch/_search?pretty=true&q=username:manh

The results are two documents that I describe above. I think ElasticSearch
also indexs field username in followers field?

I want only row have username=manhnv (parent)

Can you help me index only parent field username?

Thanks for your helping :slight_smile:

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.