Derive a new field in index mapping

Apologies if this question is very basic or already answered elsewhere. I
am new to elastic search and haven't found any related topics after a few
minutes of searching.

Given a document with the structure...

{"city":"Los Angeles", "state":"CA"}

...is it possible to set up a mapping where this document will be indexed
with a new field that can be faceted upon in addition to the source fields.
I need something equivalent to if I had indexed a document containing...

{"city":"Los Angeles", "state":"CA", "cityState":"Los Angeles, CA"}

The goal here is to be able to facet on the cityState field to get terms
and counts for unique city+state combinations. I realize I could use a
script field while faceting to get a similar result, but this would be a
preferable setup for me.

-Julian

--
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 Julian,

You can just facet on the existing city and/or state fields - no need to
add new ones.

Otis

Solr & ElasticSearch Support

On Thursday, March 21, 2013 2:35:08 PM UTC-4, jul...@usclaimsservices.com
wrote:

Apologies if this question is very basic or already answered elsewhere. I
am new to elastic search and haven't found any related topics after a few
minutes of searching.

Given a document with the structure...

{"city":"Los Angeles", "state":"CA"}

...is it possible to set up a mapping where this document will be indexed
with a new field that can be faceted upon in addition to the source fields.
I need something equivalent to if I had indexed a document containing...

{"city":"Los Angeles", "state":"CA", "cityState":"Los Angeles, CA"}

The goal here is to be able to facet on the cityState field to get terms
and counts for unique city+state combinations. I realize I could use a
script field while faceting to get a similar result, but this would be a
preferable setup for me.

-Julian

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

If you don't want to use scripts when running your facet, which is to me the more flexible solution (http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html), then, as you suggested, you have to index it in another field.

I'm afraid that you have to handle that in your application and create yourself the new field.
If you use rivers like Couchdb river, the river can help you as the river has a script filter: https://github.com/elasticsearch/elasticsearch-river-couchdb/blob/master/README.md#script-filters
That means the river update your couchdb document before sending it to ES.

HTH

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 22 mars 2013 à 05:25, Otis Gospodnetic otis.gospodnetic@gmail.com a écrit :

Hi Julian,

You can just facet on the existing city and/or state fields - no need to add new ones.

Otis

Solr & ElasticSearch Support
http://sematext.com/

On Thursday, March 21, 2013 2:35:08 PM UTC-4, jul...@usclaimsservices.com wrote:
Apologies if this question is very basic or already answered elsewhere. I am new to elastic search and haven't found any related topics after a few minutes of searching.

Given a document with the structure...

{"city":"Los Angeles", "state":"CA"}

...is it possible to set up a mapping where this document will be indexed with a new field that can be faceted upon in addition to the source fields. I need something equivalent to if I had indexed a document containing...

{"city":"Los Angeles", "state":"CA", "cityState":"Los Angeles, CA"}

The goal here is to be able to facet on the cityState field to get terms and counts for unique city+state combinations. I realize I could use a script field while faceting to get a similar result, but this would be a preferable setup for me.

-Julian

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

I heartily agree that using scripts seems more flexible. However, the documentation seems very clear that they have a significant cost in terms of search execution time. My thought was that I could make the search more snappy by indexing a new field entirely. If the only way to do this is to adjust the original document before it is indexed, then that's the route I'll have to take.

Thanks for the advice!

-Julian

From: elasticsearch@googlegroups.com [mailto:elasticsearch@googlegroups.com] On Behalf Of David Pilato
Sent: Friday, March 22, 2013 12:21 AM
To: elasticsearch@googlegroups.com
Subject: Re: Derive a new field in index mapping

If you don't want to use scripts when running your facet, which is to me the more flexible solution (http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html), then, as you suggested, you have to index it in another field.

I'm afraid that you have to handle that in your application and create yourself the new field.
If you use rivers like Couchdb river, the river can help you as the river has a script filter: https://github.com/elasticsearch/elasticsearch-river-couchdb/blob/master/README.md#script-filters
That means the river update your couchdb document before sending it to ES.

HTH

--
David Pilato | Technical Advocate | Elasticsearch.comhttp://Elasticsearch.com
@dadoonethttps://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr | @scrutmydocshttps://twitter.com/scrutmydocs

Le 22 mars 2013 à 05:25, Otis Gospodnetic <otis.gospodnetic@gmail.commailto:otis.gospodnetic@gmail.com> a écrit :

Hi Julian,

You can just facet on the existing city and/or state fields - no need to add new ones.

Otis

Solr & ElasticSearch Support

On Thursday, March 21, 2013 2:35:08 PM UTC-4, jul...@usclaimsservices.comhttp://usclaimsservices.com wrote:
Apologies if this question is very basic or already answered elsewhere. I am new to elastic search and haven't found any related topics after a few minutes of searching.

Given a document with the structure...

{"city":"Los Angeles", "state":"CA"}

...is it possible to set up a mapping where this document will be indexed with a new field that can be faceted upon in addition to the source fields. I need something equivalent to if I had indexed a document containing...

{"city":"Los Angeles", "state":"CA", "cityState":"Los Angeles, CA"}

The goal here is to be able to facet on the cityState field to get terms and counts for unique city+state combinations. I realize I could use a script field while faceting to get a similar result, but this would be a preferable setup for me.

-Julian

--
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.commailto:elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/b-x3VhOC8ic/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.commailto: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.

There were quite a few requests to support faceting on multiple fields like Sal group by multiple fields but I do not know if it is in the works...

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

There were quite a few requests to support faceting on multiple fields like SQL group by multiple fields but I do not know if it is in the works...

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