Hashes with Variable Keys


(chris-9) #1

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


(Jörg Prante) #2

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 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.
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?utm_medium=email&utm_source=footer
.
For more options, visit 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEb%3DY4LQsRt%2BL54V8BBX1_tXC76GVLDhpZipDdnYcfCAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3