Hi,
I start using ES and enjoying its features.
I'm a beginner and I have some use case and I hope ES can answer them !
Hope you can help me with my questions.
First, some context.
I have a document indexed with a title. When I defined my mappings, I also add additional field with French analyzer for the title as this:
PUT my_index
{
"mappings": {
"my_type": {
"properties": {
"title": {
"type": "text",
"fields": {
"stem": {
"type": "text",
"analyzer": "french",
}
}
}
}
}
}
}
Let's put some content:
PUT my_index/my_type/1
{
"title": "Salut, ceci est un exemple en francais les amis."
}
Now I can easily search on my title or my title.stem:
GET my_index/my_type/_search
{
"query": {
"match": {
"title.stem": "exempl"
}
}
}
Most of the time I will have to search a particular word in my title. ES can tell me if it's present on the document but (correct me if i'm wrong) can not say where in the title exactly (begin_offset / end_offset)
Here are my needs:
- I want ES to tell me if the word "exempl" is present on the document AND where exaclty (position, offset). I know it's possible to have these informations via the term_vector (search the word in title, if present call term_vector on document and retrieve the position/offset of the word by looping on each result of term_vector) but is it possible to have those informations directly in one query ?
- I also need to return two version of the title. The original and the "analyzed". I have the original title in the _source document. How can I have the "french analyzed" version ? I know about _analyze api, it can gave you the analyzed version of a given String but I would prefer to have it stored in my document (with original position, offset).
I don't know if all this is easily possible with ES or via some plugin, but I definitively need some advice on this.
Thanks for your help.