# Hashes with Variable Keys

**URL:** <https://discuss.elastic.co/t/hashes-with-variable-keys/18473>\
**Category:** Elasticsearch\
**Created:** [July 3, 2014, 8:49pm UTC](https://discuss.elastic.co/t/hashes-with-variable-keys/18473 "2014-07-03T20:49:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris\_9](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@chris\_9](https://discuss.elastic.co/u/chris_9)\
**Post date:** [July 3, 2014, 8:49pm UTC](https://discuss.elastic.co/t/hashes-with-variable-keys/18473/1 "2014-07-03T20:49:46Z")

</div>

I've got an interesting problem, where I am indexing data that contains a  
field which looks like:

"tag\_tree": {

"project1": {

```
"topic1": ["axis1"]

```

},

"project2": {

```
"topic2": ["axis1","axis2"],

"topic3": ["axis2", "axis3"]

```

}

}

The difficulty arises that I need to be able to filter something like  
{"term": {"tag\_tree.project1.\*": "axis1"}} - I have to be able to tell if  
the axis exists in any of the arrays contained by any of the topics in the  
hash.

I don't know if I need to make this possible via a mapping change, or a  
specific filter structure, or some combination of the two.

Any ideas?

Thanks,

Chris Tembreull

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4476db4b-e55e-4938-ae43-d137377741a9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4476db4b-e55e-4938-ae43-d137377741a9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [July 3, 2014, 9:45pm UTC](https://discuss.elastic.co/t/hashes-with-variable-keys/18473/2 "2014-07-03T21:45:49Z")

</div>

If you take "tag\_tree" as index, "project" as the type, and "topic" as doc  
id, you can set up a field "axis" with values of either 1,2, or 3, and you  
can filter accordingly.

An alternative would be a composite key of tag\_tree, project, topic as doc  
id.

Jörg

On Thu, Jul 3, 2014 at 10:49 PM, [chris@vendorx.com](mailto:chris@vendorx.com) wrote:

> I've got an interesting problem, where I am indexing data that contains a  
> field which looks like:
> 
> "tag\_tree": {
> 
> "project1": {
> 
> ```
> "topic1": ["axis1"]
> 
> ```
> 
> },
> 
> "project2": {
> 
> ```
> "topic2": ["axis1","axis2"],
> 
> "topic3": ["axis2", "axis3"]
> 
> ```
> 
> }
> 
> }
> 
> The difficulty arises that I need to be able to filter something like  
> {"term": {"tag\_tree.project1.\*": "axis1"}} - I have to be able to tell if  
> the axis exists in any of the arrays contained by any of the topics in the  
> hash.
> 
> I don't know if I need to make this possible via a mapping change, or a  
> specific filter structure, or some combination of the two.
> 
> Any ideas?
> 
> Thanks,
> 
> Chris Tembreull
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/4476db4b-e55e-4938-ae43-d137377741a9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4476db4b-e55e-4938-ae43-d137377741a9%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/4476db4b-e55e-4938-ae43-d137377741a9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/4476db4b-e55e-4938-ae43-d137377741a9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEb%3DY4LQsRt%2BL54V8BBX1\_tXC76GVLDhpZipDdnYcfCAw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEb%3DY4LQsRt%2BL54V8BBX1_tXC76GVLDhpZipDdnYcfCAw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:17am UTC](https://discuss.elastic.co/t/hashes-with-variable-keys/18473/3 "2017-07-06T01:17:59Z")

</div>

Closed on July 6, 2017, 1:17am UTC


