Hello everyone,
I would like to precise that I've searched before annoy you with my question but I didn't found the answer on Google or even through this forum (but maybe that it has already been asked somewhere with some other keywords).
Here is the concerned mapping :
body: {
categories: {
type: "nested",
properties: {
name: { type: "string" },
list: {
type: "nested",
properties: {
url_site: { type: "string" },
persons: {
total_customers: { type: "integer" },
total_subscribers: { type: "integer" },
details: {
type: "nested",
properties: {
person_id: { type: "string" },
person_date_registration: { type: "date" },
person_date_subscription: { type: "date" }
}
}
}
}
}
}
}
}
Yeah, I know, complex mapping. But my question is kind of tricky. I'm trying to do a research through the javascript API like this :
elasticClient.search({
index: indexName,
type: typeName,
q: customer_id
}).then(function (body) {
return body.hits.hits[0];
}, function (err) {
console.trace("\nTRACE : " + err.message);
});
Do you know how I could pass a correct q parameter to search all the persons with the person_id equals to my customer_id ?
I tried the following using SENSE but failed (hard customer ID given):
POST /indexName/typeName/_search
{
"query": {
"bool": {
"must": {
"match": {
"categories.list.persons.details.person_id": "50"
}
}
}
}
}
and even
POST /indexName/typeName/_search
{
"query": {
"nested": {
"path": "categories[0].list[0].persons",
"query": {
"bool": {
"must": [
{
"match": {
"categories[0].list[0].persons.id": 50
}
}
]
}
}
}
}
}
You guys already help me a lot with ElasticSearch and I know that here is the best place to ask this question.
Have a good day.
A lost intern.