Search a dot in string with wildcard


(Michele) #1

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?


(David Pilato) #2

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


(system) #3

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