Getting offsets of a keyword in documents


(Kumar) #1

I'm new to Elasticsearch. I have created an index named "files". Then I have added a document with fields 'name' & 'content', under the type "text". like below.
curl -XPUT 'localhost:9200/files/text/1?pretty' -H 'Content-Type: application/json' -d'
{
"name" : "Readme",
"content" : "Hi this is a sample document.I created this document to explore the features of elasticsearch"
}'

I want to search in the 'content' field of this document for a keyword [for eg.'this'] and get its offsets. Is it possible ?. Actually my requirement is to get the offsets of a keyword in 'n' documents in an index


(Xavier Facq) #2

Hi, maybe you can look at this : https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html


(Kumar) #3

thanks. I tried it. but it only highlights the occurrences. I want its offsets .


(system) #4

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