Is there a query besides query_string that can do "and" search across multiple fields?

is there a query besides query_string that can do "and" search across
multiple fields?

--
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.

On Fri, 2013-03-29 at 06:06 -0700, AlexR wrote:

is there a query besides query_string that can do "and" search across
multiple fields?

multi_match

but the behaviour differs. query_string looks for each search term in
each field. multi_match looks for all terms in a single field.

have a look at:

clint

--
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.

Hi Clint,

I should have qualify it better. I am not interested in multi_match as it
does not search across fields but within (as you said just execute the same
query against all the fields so a doc with one query term in field A and
the other in B won't be retrieved)

As far as I can say there is no way to achieve searching across multiple
fields with any query but query_string. I am wondering why there is on such
query in ES as it seems to be an pretty common use case?

My very naive thinking is that it could be implemented by finding doc IDs
for each term in each field and then reducing them to those that have every
field covered (and scoring them)

Thank you,
Alex

On Fri, Mar 29, 2013 at 9:38 AM, Clinton Gormley clint@traveljury.comwrote:

On Fri, 2013-03-29 at 06:06 -0700, AlexR wrote:

is there a query besides query_string that can do "and" search across
multiple fields?

multi_match

but the behaviour differs. query_string looks for each search term in
each field. multi_match looks for all terms in a single field.

have a look at:

search - Multi-field, multi-word, match without query_string - Stack Overflow

clint

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Vt_WiHgKspw/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, 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.

Hi Alex

As far as I can say there is no way to achieve searching across
multiple fields with any query but query_string. I am wondering why
there is on such query in ES as it seems to be an pretty common use
case?

In order to do this, you have to preparse the query string, eg if you
want to do an AND search in field_1 and field_2, a query for "foo bar"
becomes:

+(field_1:foo | field_2:foo) +(field_1:bar | field_2:bar)

But what happens if "foo bar" is a synonym for "foobar" in field_1? Then
this query won't work. What happens if field_1 is analyzed differently
from field_2? Again, unexpected results, because your query terms have
already been preparsed.

It's a minefield.

If you want to query multiple fields as if they were a single field,
then create your own custom _all field which contains the data from all
the involved fields, as I described here:

clint

--
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.

I would not try to do it via a complex query as you said it is a mindfield
and unless you cover all the permutations is not reliable ot needs to be
done algorithmically like i described above

I do useultifield for the job but it has its own problems such as its
analysisay not be suitable for all fields that contrinuye to it (say you
have person name and a quote in a multifield and you want the quote stemmed
but not person name) another is highlighting of individual fields of the
multifield if they are not analized like the multifield they would not be
highlighted

My trouble is that we have couple fundreds of fields to search across and I
need to have good relevanve and highlight every individual field that
matched
On Mar 30, 2013 4:55 AM, "Clinton Gormley" clint@traveljury.com wrote:

Hi Alex

As far as I can say there is no way to achieve searching across
multiple fields with any query but query_string. I am wondering why
there is on such query in ES as it seems to be an pretty common use
case?

In order to do this, you have to preparse the query string, eg if you
want to do an AND search in field_1 and field_2, a query for "foo bar"
becomes:

+(field_1:foo | field_2:foo) +(field_1:bar | field_2:bar)

But what happens if "foo bar" is a synonym for "foobar" in field_1? Then
this query won't work. What happens if field_1 is analyzed differently
from field_2? Again, unexpected results, because your query terms have
already been preparsed.

It's a minefield.

If you want to query multiple fields as if they were a single field,
then create your own custom _all field which contains the data from all
the involved fields, as I described here:

search - Multi-field, multi-word, match without query_string - Stack Overflow

clint

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Vt_WiHgKspw/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, 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.

Multi_field
: Elasticsearch Platform — Find real-time answers at scale | Elastic

"tweet" : {
    "properties": {
        "first_name": {
            "type": "multi_field",
            "path": "just_name",
            "fields": {
                "first_name": {"type": "string", "index": "analyzed"},
                "any_name": {"type": "string","index": "analyzed"}
            }
        },
        "last_name": {
            "type": "multi_field",
            "path": "just_name",
            "fields": {
                "last_name": {"type": "string", "index": "analyzed"},
                "any_name": {"type": "string","index": "analyzed"}
            }
        }
    }
}

}

With this mapping you can either search individually for first_name,
last_name, or for a virtual field : any_name combining first_name and
last_name.
But you have to specify it in your mapping, not a query time !

Le samedi 30 mars 2013 11:49:25 UTC-4, AlexR a écrit :

I would not try to do it via a complex query as you said it is a mindfield
and unless you cover all the permutations is not reliable ot needs to be
done algorithmically like i described above

I do useultifield for the job but it has its own problems such as its
analysisay not be suitable for all fields that contrinuye to it (say you
have person name and a quote in a multifield and you want the quote stemmed
but not person name) another is highlighting of individual fields of the
multifield if they are not analized like the multifield they would not be
highlighted

My trouble is that we have couple fundreds of fields to search across and
I need to have good relevanve and highlight every individual field that
matched
On Mar 30, 2013 4:55 AM, "Clinton Gormley" <cl...@traveljury.com<javascript:>>
wrote:

Hi Alex

As far as I can say there is no way to achieve searching across
multiple fields with any query but query_string. I am wondering why
there is on such query in ES as it seems to be an pretty common use
case?

In order to do this, you have to preparse the query string, eg if you
want to do an AND search in field_1 and field_2, a query for "foo bar"
becomes:

+(field_1:foo | field_2:foo) +(field_1:bar | field_2:bar)

But what happens if "foo bar" is a synonym for "foobar" in field_1? Then
this query won't work. What happens if field_1 is analyzed differently
from field_2? Again, unexpected results, because your query terms have
already been preparsed.

It's a minefield.

If you want to query multiple fields as if they were a single field,
then create your own custom _all field which contains the data from all
the involved fields, as I described here:

search - Multi-field, multi-word, match without query_string - Stack Overflow

clint

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Vt_WiHgKspw/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearc...@googlegroups.com <javascript:>.
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.