ElasticSearch with n word separation and regular expression (with Tire gem)

I am using ElasticSearch (with the Tire gem). I have the following query
which will match escaped cat, escaped black cat, etc.

I was wondering, is it possible to ask ElasticSearch to search with the
following criteria:

  1. "escaped [exactly 0 or 1 word] cat" ie) escaped \w{0,1} cat
  2. "escaped [n words] cat" ie) escaped \w{n} cat
  3. "escaped [Regular expression here] cat" ie) escaped (big|black|white)
    cat

Thanks

Current searching query:

{
"query": {
"bool": {
"should": [
{
"query_string": {
"query": ""escaped ? cat"",
"analyzer": "snowball"
}
},
{
"query_string": {
"query": ""escaped ? cat"",
"default_operator": "and"
}
},
{
"flt_field": {
"content": {
"like_text": ""escaped ? cat""
}
}
},
{
"mlt_field": {
"content": {
"like_text": ""escaped ? cat""
}
}
}
]
}
}}

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hey,

the slop parameter might help you in your first two cases. (Search for slop
on the .org documentation, it is mentioned in the match and in the
query_string query at least). Your regular expression case might be
solvable with the regexp filter, but it might be to slow. You might be able
to work around by using a bool query and the minimum_should_match parameter
http://www.elasticsearch.org/guide/reference/query-dsl/bool-query/
http://www.elasticsearch.org/guide/reference/query-dsl/minimum-should-match/

I am afraid I cannot help you with Tire though...

--Alex

On Thu, Jul 18, 2013 at 6:06 PM, William bill@theworkinggroup.ca wrote:

I am using ElasticSearch (with the Tire gem). I have the following query
which will match escaped cat, escaped black cat, etc.

I was wondering, is it possible to ask ElasticSearch to search with the
following criteria:

  1. "escaped [exactly 0 or 1 word] cat" ie) escaped \w{0,1} cat
  2. "escaped [n words] cat" ie) escaped \w{n} cat
  3. "escaped [Regular expression here] cat" ie) escaped
    (big|black|white) cat

Thanks

Current searching query:

{
"query": {
"bool": {
"should": [
{
"query_string": {
"query": ""escaped ? cat"",
"analyzer": "snowball"
}
},
{
"query_string": {
"query": ""escaped ? cat"",
"default_operator": "and"
}
},
{
"flt_field": {
"content": {
"like_text": ""escaped ? cat""
}
}
},
{
"mlt_field": {
"content": {
"like_text": ""escaped ? cat""
}
}
}
]
}
}}

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.