0

Following the documentation's canonical example, say I want to store tweets in elasticsearch, but I want to specify an endpoint that handles more than two fields, e.g.

/tweets/some_twitter_handle/some_month/tweet/id

In this example, I want to index on tweets, but also on some_twitter_handle and some_month, with tweet type, and some id.

Is this possible, or is the only possible mapping something akin to what they provide, with one index and one type, e.g /tweets/tweet/id?

1 Answer 1

1

The index/type/id is what determines which shard a document ends up on (in the absense of other routing information). Elasticsearch indexes every field by default (you can control this through a mapping if you don't want some of your field indexed). So by putting a "twitter_handle": "whatever" into the document, it becomes searchable by that "twitter_handle".

Sign up to request clarification or add additional context in comments.

4 Comments

Cool. I'm kind of new to this; is searching for a twitter handle with the mapping /tweets/tweet/id (where tweet would house a twitter_handle) more computationally expensive than having the mapping: /tweets/twitter_handle/id? That's mostly my concern.
/tweets/tweet/id would be a specific twitter message. If you were to try to put all of a specific person's tweets into a single document (ie if id were a twitter handle), it would be very inefficient.
/tweets/twitter_handle/id would still be a single twitter message, but in the former example, the twitter_handle would be a field in the tweet, whereas in the latter, it's just a more specific routing.
The mapping for any given document in ES is based on its index and type. So using twitter_handle as a type makes it awkward to create a mapping that applies to all tweets. You would have to create a mapping template to make sure all of your types were right.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.