Searching key names as well


(bcoder) #1

I have documents of following form indexed in ES:

{
"foo1":
{
"blah1": "hello1",
"blah2": "hello2"
}
}

I want to be able to search a prefix, inside "foo1" hash (both key
names and values should be searched). So for example if I search
"blah1", then it should be a valid match (in the example above: since
a key with "blah1" exist). Similarly "hello1" is also a valid match
(key value).

Is there a way to do that ?

I know that I can search something like this: {"query": {"prefix":
{"foo1.blah1": "hello1"}}}, but this does not: 1) search entire "foo1"
hash, 2) Search only key value of specified key (foo1.blah1 in this
case), and not the strings representing key names.

I want to be able to say something like: Find me all documents which
have some "text" inside the hash "foo1" (irrespective of the fact,
wheter the text matches a key name or key value).

Note: The keys inside "foo1" hash are arbitrary and potentially
different for each hash (both the actual name of keys and also number
of them)

Thanks in advance!


(Shay Banon) #2

There isn't a way to do it unless you explicitly search on all the fields.
There has been some discussions on automatically building a compound query
based on a wildcarded name, something like foo.*, but it hasn't move
further than the discussion.

On Tue, May 1, 2012 at 6:53 AM, bcoder blitzkriegcoder@gmail.com wrote:

I have documents of following form indexed in ES:

{
"foo1":
{
"blah1": "hello1",
"blah2": "hello2"
}
}

I want to be able to search a prefix, inside "foo1" hash (both key
names and values should be searched). So for example if I search
"blah1", then it should be a valid match (in the example above: since
a key with "blah1" exist). Similarly "hello1" is also a valid match
(key value).

Is there a way to do that ?

I know that I can search something like this: {"query": {"prefix":
{"foo1.blah1": "hello1"}}}, but this does not: 1) search entire "foo1"
hash, 2) Search only key value of specified key (foo1.blah1 in this
case), and not the strings representing key names.

I want to be able to say something like: Find me all documents which
have some "text" inside the hash "foo1" (irrespective of the fact,
wheter the text matches a key name or key value).

Note: The keys inside "foo1" hash are arbitrary and potentially
different for each hash (both the actual name of keys and also number
of them)

Thanks in advance!


(bcoder) #3

Thanks for the swift reply! :slight_smile:

On May 2, 9:23 am, Shay Banon kim...@gmail.com wrote:

There isn't a way to do it unless you explicitly search on all the fields.
There has been some discussions on automatically building a compound query
based on a wildcarded name, something like foo.*, but it hasn't move
further than the discussion.

On Tue, May 1, 2012 at 6:53 AM, bcoder blitzkriegco...@gmail.com wrote:

I have documents of following form indexed in ES:

{
"foo1":
{
"blah1": "hello1",
"blah2": "hello2"
}
}

I want to be able to search a prefix, inside "foo1" hash (both key
names and values should be searched). So for example if I search
"blah1", then it should be a valid match (in the example above: since
a key with "blah1" exist). Similarly "hello1" is also a valid match
(key value).

Is there a way to do that ?

I know that I can search something like this: {"query": {"prefix":
{"foo1.blah1": "hello1"}}}, but this does not: 1) search entire "foo1"
hash, 2) Search only key value of specified key (foo1.blah1 in this
case), and not the strings representing key names.

I want to be able to say something like: Find me all documents which
have some "text" inside the hash "foo1" (irrespective of the fact,
wheter the text matches a key name or key value).

Note: The keys inside "foo1" hash are arbitrary and potentially
different for each hash (both the actual name of keys and also number
of them)

Thanks in advance!


(system) #4