Search a dot in string with wildcard

In my index I have:

  • doc1 ==> field1 = foo 123, field2 = 123
  • doc2 ==> field1 = f.o.o 456, field2 = 456

If I do this query, I have returned doc1:

{
	"query":{
		"bool":{
			"must":[
				{"wildcard":{"field1" : "foo*"}},
				{"term":{"field2": "123"}}
				]
		}
	}
}

If I do this query, I have returned empty results:

{
	"query":{
		"bool":{
			"must":[
				{"wildcard":{"field1" : "*456"}},
				{"term":{"field2": "456"}}
				]
		}
	}
}

I have returned doc2.

If I do this query, I have returned empty results:

{
	"query":{
		"bool":{
			"must":[
				{"wildcard":{"field1" : "f.o.o*"}},
				{"term":{"field2": "456"}}
				]
		}
	}
}

I think that the problem is the dot character in field1.

How can I search with regex for finding string that has dot inside?

It depends on the analyzer you are using for your field as wildcard query is not analyzed.

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