Possible to have something like _all with own name for specific fields?

Hi,

is it possible to have a field similar to _all but with its own name and
only for specific fields of the source document?

As an example, two docs of the same type with two fields "linkA" and
"linkB" which should be mapped to _links:

Doc 1: {"linkA": "http://0000.com", "linkB": "http://0001.com"}
Doc 2: {"linkA": "http://0010.com", "linkB": "http://0011.us"}

Now I don't want linkA and linkB to be included in _all but, let's say, in
_links so I can search for any link like this:

{"filter": {"term": {"_links": "http://0010.com"}}} -> Doc 2

Is this perhaps possible by using multi_field and mapping to an identical
_links name for linkA and linkB?

Cheers
Stephan

--

I usually handle this behavior on the indexing side, outside of
Elasticsearch. Related fields use the same field name.

Do you need the _all field in general? If you don't, you can
set include_in_all to false for every field except the link fields. If not,
there is an index_name setting in the mapping that I have never used. From
the description, it sounds like it should support what you are looking for.
Multi-field would not work since they are based off of the original field.

--
Ivan

On Fri, Jan 4, 2013 at 12:57 AM, Stephan Seidt evilhackerdude@gmail.comwrote:

Hi,

is it possible to have a field similar to _all but with its own name and
only for specific fields of the source document?

As an example, two docs of the same type with two fields "linkA" and
"linkB" which should be mapped to _links:

Doc 1: {"linkA": "http://0000.com", "linkB": "http://0001.com"}
Doc 2: {"linkA": "http://0010.com", "linkB": "http://0011.us"}

Now I don't want linkA and linkB to be included in _all but, let's say, in
_links so I can search for any link like this:

{"filter": {"term": {"_links": "http://0010.com"}}} -> Doc 2

Is this perhaps possible by using multi_field and mapping to an identical
_links name for linkA and linkB?

Cheers
Stephan

--

--

Besides using the _all field and index_name attribute as Ivan suggested,
you can also use mutli_match query to search multiple fields at the same
time:

    "multi_match": {
        "query" : "your query goes here",
        "fields" : [ "link*" ]        
    }

or use mutli_field with "path": "just_name" attribute to copy content of
several fields into a single
field: Сopy multiple fields into a single field in ElasticSearch · GitHub

On Friday, January 4, 2013 12:29:00 PM UTC-5, Ivan Brusic wrote:

I usually handle this behavior on the indexing side, outside of
Elasticsearch. Related fields use the same field name.

Do you need the _all field in general? If you don't, you can
set include_in_all to false for every field except the link fields. If not,
there is an index_name setting in the mapping that I have never used. From
the description, it sounds like it should support what you are looking for.
Multi-field would not work since they are based off of the original field.

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

--
Ivan

On Fri, Jan 4, 2013 at 12:57 AM, Stephan Seidt <evilhac...@gmail.com<javascript:>

wrote:

Hi,

is it possible to have a field similar to _all but with its own name and
only for specific fields of the source document?

As an example, two docs of the same type with two fields "linkA" and
"linkB" which should be mapped to _links:

Doc 1: {"linkA": "http://0000.com", "linkB": "http://0001.com"}
Doc 2: {"linkA": "http://0010.com", "linkB": "http://0011.us"}

Now I don't want linkA and linkB to be included in _all but, let's say,
in _links so I can search for any link like this:

{"filter": {"term": {"_links": "http://0010.com"}}} -> Doc 2

Is this perhaps possible by using multi_field and mapping to an identical
_links name for linkA and linkB?

Cheers
Stephan

--

--

Using multi_field to copy relevant fields into a single field is what's
best I think.

With multi_match or a boolean query there'd be a problem: All possible
fields are not easily known at query time and the list can be large.

For that reason I'll choose the optimization of having a single compound
field at indexing time.

Thank you both for your help!
Stephan

On Monday, January 7, 2013 2:30:13 AM UTC+1, Igor Motov wrote:

Besides using the _all field and index_name attribute as Ivan suggested,
you can also use mutli_match query to search multiple fields at the same
time:

    "multi_match": {
        "query" : "your query goes here",
        "fields" : [ "link*" ]        
    }

or use mutli_field with "path": "just_name" attribute to copy content of
several fields into a single field:
Сopy multiple fields into a single field in ElasticSearch · GitHub

On Friday, January 4, 2013 12:29:00 PM UTC-5, Ivan Brusic wrote:

I usually handle this behavior on the indexing side, outside of
Elasticsearch. Related fields use the same field name.

Do you need the _all field in general? If you don't, you can
set include_in_all to false for every field except the link fields. If not,
there is an index_name setting in the mapping that I have never used. From
the description, it sounds like it should support what you are looking for.
Multi-field would not work since they are based off of the original field.

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

--
Ivan

On Fri, Jan 4, 2013 at 12:57 AM, Stephan Seidt evilhac...@gmail.comwrote:

Hi,

is it possible to have a field similar to _all but with its own name and
only for specific fields of the source document?

As an example, two docs of the same type with two fields "linkA" and
"linkB" which should be mapped to _links:

Doc 1: {"linkA": "http://0000.com", "linkB": "http://0001.com"}
Doc 2: {"linkA": "http://0010.com", "linkB": "http://0011.us"}

Now I don't want linkA and linkB to be included in _all but, let's say,
in _links so I can search for any link like this:

{"filter": {"term": {"_links": "http://0010.com"}}} -> Doc 2

Is this perhaps possible by using multi_field and mapping to an
identical _links name for linkA and linkB?

Cheers
Stephan

--

--