Regexp not working in head plugin


(Ronny Deter) #1

The regexp query or filter not working in my case.
Here my data

{ "index" : { "_index" : "map", "_type" : "item", "_id" : 1 }}

{ "name" : "New York", "combined" : "2014-BBBFFFBBBFFF" }

{ "index" : { "_index" : "map", "_type" : "item", "_id" : 2 }}

{ "name" : "London", "combined" : "2015-FFFFFBBBBFFFF" }

{ "index" : { "_index" : "map", "_type" : "item", "_id" : 3 }}

{ "name" : "Moscow", "combined" : "2014-FFFFFBBBBBBBBBB"}

{ "index" : { "_index" : "map", "_type" : "item", "_id" : 4 }}

{ "name" : "Sydney", "combined" : "2015-BBBBBBBBBBBBBBBB" }

My search query

{

"query": {

"regexp": {

  "item.combined": "2014-b{3}f{3}*"

}

},

"from": 0,

"size": 25

}
to find the first entry, but is not working.

What i wnat to do is search in combined for a year and substr at position x
to position y with a f. Any character before or after positions can be any
character.
When i create a regex on http://regex101.com/ to find f in the string it
has this regex 2014-.{3}F{3}.* to match 2014-BBBFFFBBBFFF

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b7f2a8cb-8887-4d90-bbd6-9c32e1250c6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Alexander Reelsen) #2

Hey,

keep in mind, that the regexp query is a term query with regex support, so
having analyzed fields is a problem, try the following example:

DELETE /map
PUT /map

PUT /map/item/_mapping
{
"properties": {
"combined" : { "type": "string", "index": "not_analyzed"}
}
}

GET /map/item/_mapping

PUT /_bulk
{ "index" : { "_index" : "map", "_type" : "item", "_id" : 1 }}
{ "name" : "New York", "combined" : "2014-BBBFFFBBBFFF" }
{ "index" : { "_index" : "map", "_type" : "item", "_id" : 2 }}
{ "name" : "London", "combined" : "2015-FFFFFBBBBFFFF" }
{ "index" : { "_index" : "map", "_type" : "item", "_id" : 3 }}
{ "name" : "Moscow", "combined" : "2014-FFFFFBBBBBBBBBB"}
{ "index" : { "_index" : "map", "_type" : "item", "_id" : 4 }}
{ "name" : "Sydney", "combined" : "2015-BBBBBBBBBBBBBBBB" }

GET /map/_search
{
"query": {
"regexp": {
"item.combined": "2014-B{3}F{3}.*"
}
},
"from": 0,
"size": 25
}

As you can see, I changed the mapping and the regex slightly.. not sure if
it helps you.

--Alex

On Fri, Apr 11, 2014 at 2:55 PM, ronny.deter@campanda.com wrote:

The regexp query or filter not working in my case.
Here my data

{ "index" : { "_index" : "map", "_type" : "item", "_id" : 1 }}

{ "name" : "New York", "combined" : "2014-BBBFFFBBBFFF" }

{ "index" : { "_index" : "map", "_type" : "item", "_id" : 2 }}

{ "name" : "London", "combined" : "2015-FFFFFBBBBFFFF" }

{ "index" : { "_index" : "map", "_type" : "item", "_id" : 3 }}

{ "name" : "Moscow", "combined" : "2014-FFFFFBBBBBBBBBB"}

{ "index" : { "_index" : "map", "_type" : "item", "_id" : 4 }}

{ "name" : "Sydney", "combined" : "2015-BBBBBBBBBBBBBBBB" }

My search query

{

"query": {

"regexp": {

  "item.combined": "2014-b{3}f{3}*"

}

},

"from": 0,

"size": 25

}
to find the first entry, but is not working.

What i wnat to do is search in combined for a year and substr at position
x to position y with a f. Any character before or after positions can be
any character.
When i create a regex on http://regex101.com/ to find f in the string it
has this regex 2014-.{3}F{3}.* to match 2014-BBBFFFBBBFFF

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/b7f2a8cb-8887-4d90-bbd6-9c32e1250c6b%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/b7f2a8cb-8887-4d90-bbd6-9c32e1250c6b%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-UtDtS7aKsn%3D9ba-70GSNq8TYUcve-5ZUSuzpSTwsKNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3