j0nnybrav0
j0nnybrav0

Reputation: 123

Elastic search - get position from result

is there a way to get the position for a result in elastic search?

Lets say I have the following document:

"Lorem ipsum dolor sit amet, john HALLO doe consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et john HALLO doe dolore magna aliquyam erat john HALLO doe, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum."

Now I search for "HALLO" and get three hits, and some words before and after each hit ("john HALLO doe"). My problem is, that these words could be equal.

So is there a more fancy way to get the exact position from the hit in the document, like e.g. ">HALLO< [line, char-start - char-end]"?

Upvotes: 2

Views: 1648

Answers (1)

Lupanoide
Lupanoide

Reputation: 3222

Yes, with the termvector api, doc here. You have to enable the offset param. Follow the example in the doc

Upvotes: 2

Related Questions