Hello,
I have simple question about searching on text field.
Let's assume we have a text field message with value:
This is example of search query. Can anyone help me?
PUT index
{
"mappings": {
"properties": {
"message" : {
"type" : "text"
}
}
}
}
POST index/_doc
{
"message": "This is example of search query. Can anyone help me?"
}
I'm using standard analyzer. So sentence is tokenized like this:
POST _analyze
{
"text": "This is example of search query. Can anyone help me?",
"analyzer": "standard"
}
I found out that wildcard is possible to apply only on tokenized terms.
POST index/_search
{
"query": {
"query_string": {
"default_field": "message",
"query": "s*r*h"
}
}
}
and
GET index/_search
{
"query": {
"wildcard": {
"message": {
"value": "s*r*h*"
}
}
}
}
and
GET index/_search
{
"query": {
"regexp": {
"message": {
"value": "s.*ch",
"flags": "ALL"
}
}
}
}
Is it possible to perform query on field message that will met these requirements?
- field begins with tokens this, is
- somewhere after these tokens is token that
- field ends with token me
or is necessary to index field message as keyword type too and perform regexp query like: /^This is.*that.*me/