Hi! Is it possible in elastic to make one request with two linked queries -
so a first one returns some values and second one uses these values as
parameters? For example - search for users based on some input parameters
and current user's settings. Settings could be very large and they'd better
stay in elastic than be specified in each request body. Is it possible?
So what you're hoping to avoid is returning the user settings from the
first query only to send have to send them again as a second query?
Unfortunately Elasticsearch doesn't provide functionality for this (I was
thinking maybe using scripting however it doesnt provide the necessary API).
If you're able to provide a little more information we might be able to see
where optimizations can be made.
On Wednesday, November 7, 2012 7:48:39 PM UTC+11, Eugene Nikolaev wrote:
Hi! Is it possible in elastic to make one request with two linked queries
so a first one returns some values and second one uses these values as
parameters? For example - search for users based on some input parameters
and current user's settings. Settings could be very large and they'd better
stay in elastic than be specified in each request body. Is it possible?
Thanks for your reply! I am hoping to avoid some network traffic, because
user settings could include for example array of identies of rejected
users. So if a user performs search for possible friends, these rejected
users should not be included in the search result. A user can reject as
many users as he or she wants. Say, 100-1000 ids. And I was hoping ther was
a way to avoid this traffic overhead - first query loads a user, then
second query fetches users using some input parameters and the array of the
rejected user ids from first query result.
Could one not write a custom request action for this sort of stuff?
This is not currently pluggable, so one would have to modify and rebuild
ES, but it could be done, no?
On Wednesday, November 7, 2012 5:34:33 AM UTC-5, Chris Male wrote:
Hi Eugene,
So what you're hoping to avoid is returning the user settings from the
first query only to send have to send them again as a second query?
Unfortunately Elasticsearch doesn't provide functionality for this (I was
thinking maybe using scripting however it doesnt provide the necessary API).
If you're able to provide a little more information we might be able to
see where optimizations can be made.
On Wednesday, November 7, 2012 7:48:39 PM UTC+11, Eugene Nikolaev wrote:
Hi! Is it possible in elastic to make one request with two linked queries
so a first one returns some values and second one uses these values as
parameters? For example - search for users based on some input parameters
and current user's settings. Settings could be very large and they'd better
stay in elastic than be specified in each request body. Is it possible?
I think it can be done as a plugin. It's quite different from search. So it
would make sense to implement it as a new request. As a result it wouldn't
have to intersept anything. It would be somewhat similar to More Like This
API http://www.elasticsearch.org/guide/reference/api/more-like-this.htmlbut instead of creating query based on a document content, it would build a
query based on query template and results of another query. I just don't
see how to formulate such request in such a way that it would
be consistent with other es requests, easy to understand and flexible. It
looks like someone would have to design some sort of a templating language
to make such plugin really useful.
On Wednesday, November 7, 2012 2:39:06 PM UTC-5, Otis Gospodnetic wrote:
Chris,
Could one not write a custom request action for this sort of stuff?
This is not currently pluggable, so one would have to modify and rebuild
ES, but it could be done, no?
On Wednesday, November 7, 2012 5:34:33 AM UTC-5, Chris Male wrote:
Hi Eugene,
So what you're hoping to avoid is returning the user settings from the
first query only to send have to send them again as a second query?
Unfortunately Elasticsearch doesn't provide functionality for this (I was
thinking maybe using scripting however it doesnt provide the necessary API).
If you're able to provide a little more information we might be able to
see where optimizations can be made.
On Wednesday, November 7, 2012 7:48:39 PM UTC+11, Eugene Nikolaev wrote:
Hi! Is it possible in elastic to make one request with two linked
queries - so a first one returns some values and second one uses these
values as parameters? For example - search for users based on some input
parameters and current user's settings. Settings could be very large and
they'd better stay in elastic than be specified in each request body. Is it
possible?
I agree with Igor, I think it could definitely be done via a plugin.
One way for a generic solution would be to allow a script to be used to
build the request based on the results of a previous request.
On Thursday, November 8, 2012 1:23:02 PM UTC+11, Igor Motov wrote:
Otis,
I think it can be done as a plugin. It's quite different from search. So
it would make sense to implement it as a new request. As a result it
wouldn't have to intersept anything. It would be somewhat similar to More
Like This APIhttp://www.elasticsearch.org/guide/reference/api/more-like-this.htmlbut instead of creating query based on a document content, it would build a
query based on query template and results of another query. I just don't
see how to formulate such request in such a way that it would
be consistent with other es requests, easy to understand and flexible. It
looks like someone would have to design some sort of a templating language
to make such plugin really useful.
On Wednesday, November 7, 2012 2:39:06 PM UTC-5, Otis Gospodnetic wrote:
Chris,
Could one not write a custom request action for this sort of stuff?
This is not currently pluggable, so one would have to modify and rebuild
ES, but it could be done, no?
On Wednesday, November 7, 2012 5:34:33 AM UTC-5, Chris Male wrote:
Hi Eugene,
So what you're hoping to avoid is returning the user settings from the
first query only to send have to send them again as a second query?
Unfortunately Elasticsearch doesn't provide functionality for this (I was
thinking maybe using scripting however it doesnt provide the necessary API).
If you're able to provide a little more information we might be able to
see where optimizations can be made.
On Wednesday, November 7, 2012 7:48:39 PM UTC+11, Eugene Nikolaev wrote:
Hi! Is it possible in elastic to make one request with two linked
queries - so a first one returns some values and second one uses these
values as parameters? For example - search for users based on some input
parameters and current user's settings. Settings could be very large and
they'd better stay in elastic than be specified in each request body. Is it
possible?
Thank you all for your replies! We have guessed how to make a workaround
for this. We just have to inverse rejected users -> user relation and save
ids of users who has ignored a user in his or her entry. So we only need to
pass a current user id to exclude users who was ignored by him or her from
search result. I think some scripting will be enough. Thanks again!
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.