Query multiple document types


#1

Hi,

I'm at the very start with ELK and have a question. I have 1 index that contains 2 document types, the first type contains the main info and the second contains multiple entries that relate to a key value in the first.

I can't see how I can query to extract data from both documents?

Any help is much appreciated


(Felix Stürmer) #2

Hi @JohnG,

performing queries across multiple documents is only supported in a limited fashion in elasticsearch, because it is built to support a horizontal scaling strategy. Nevertheless, there are the has_child, has_parent and parent_id queries, which might help you - depending on your document structure. See the documentation regarding joining queries for details.


#3

Thanks for the response Felix.

I have found some mapping instructions (here is an example).

PUT /company
{
"mappings": {
"branch": {},
"employee": {
"_parent": {
"type": "branch"
}
}
}
}

Where would this code go? in the elasticsearch.yml?

Thanks.


(Felix Stürmer) #4

To define mappings you have to send PUT requests like these to the Elasticsearch server after it has been started. You could to that using curl, for example:

$ curl -X PUT 'http://localhost:9200/company' -d '{"mappings": {...}}'

The documentation on the indices api offers more examples.


#5

Ah, ok.

Many thanks :slight_smile:


(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.