You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Indika Tantrigoda <in...@gmail.com> on 2012/11/18 15:14:56 UTC

Execute an independent query from the main query

Hi All,

I would like to get results of an query that is different from the main
query as a new field. This query needs to be independent from any filter
queries applied to the main query. I was trying to achieve this by
fl=_external_query_result:query($myQuery), however that result seems to be
governed by any filter queries applied to the main query ? Is it possible
to have a completely separate query in the fl list and return its result
along with the results (per results), or would I need to create a separate
query on the client side to get the results of the independent query (based
on the results from the first query) ?

Thanks in advance,
Indika

Re: Execute an independent query from the main query

Posted by Indika Tantrigoda <in...@gmail.com>.
Hi Otis,

Yes, that seems like one solution, however I  have multiple opening and
closing hours, within the same day. Therefore it might become somewhat
complicated to manage the index. For now I shifted the business logic to
the client and a second query is made to get the additional data. Thanks
for the suggestion.

Indika

On 20 November 2012 02:50, Otis Gospodnetic <ot...@gmail.com>wrote:

> Hi Indika,
>
> So my suggestion was to maybe consider changing the index structure and
> pull open/close times into 1 or more fields in the main record, so you
> don't have this problem all together.
>
> Otis
> --
> Performance Monitoring - http://sematext.com/spm/index.html
> Search Analytics - http://sematext.com/search-analytics/index.html
>
>
>
>
> On Sun, Nov 18, 2012 at 10:39 PM, Indika Tantrigoda <indika85@gmail.com
> >wrote:
>
> > Hi Otis,
> >
> > Actually I maintain a separate document for each open/close time along
> with
> > the date (i.e. Sunday =1, Monday =2). I was thinking if it would be
> > possible to query Solr asking, give the next day's (can be current_day
> +1)
> > minimum opening time as a response field.
> >
> > Thanks,
> > Indika
> >
> > On 19 November 2012 04:50, Otis Gospodnetic <otis.gospodnetic@gmail.com
> > >wrote:
> >
> > > Hi,
> > >
> > > Maybe your index needs to have a separate field for each day open/close
> > > time. No join or extra query needed then.
> > >
> > > Otis
> > > --
> > > Performance Monitoring - http://sematext.com/spm
> > > On Nov 18, 2012 5:35 PM, "Indika Tantrigoda" <in...@gmail.com>
> wrote:
> > >
> > > > Thanks for the response.
> > > >
> > > > Erick,
> > > > My use case is related to restaurant opening hours, In the same
> request
> > > to
> > > > Solr I'd like to get the time when the restaurant opens the next
> > > > day, preferably part of the fields returned, and this needs to be
> > > > independent of the main queries search params.
> > > >
> > > > Yes, the Join wouldn't be suitable in this use case.
> > > >
> > > > Luis,
> > > > I had thought of having the logic in the client side, but before
> that I
> > > > wanted to see if I could get the result from Solr itself. I
> > > > am currently using SolrJ along with Spring.
> > > >
> > > > Thanks,
> > > > Indika
> > > >
> > > > On 18 November 2012 21:49, Luis Cappa Banda <lu...@gmail.com>
> > wrote:
> > > >
> > > > > Hello!
> > > > >
> > > > > When queries become more and more complex and you need to apply one
> > > > second
> > > > > query with the resultant docs from the first one, or re-sort
> results,
> > > or
> > > > > maybe add some promotional or special docs to the response, I
> > recommend
> > > > to
> > > > > develop a Web App module that implements that complex business
> logic
> > > and
> > > > > dispatches queries from your Client App to your Solr back-end. That
> > > > module,
> > > > > let's call Search Engine, lets you play with all those special use
> > > cases.
> > > > > If you are familiar with Java I suggest you to have a look at the
> > > > > combination between SolrJ and Spring framework or Jersey.
> > > > >
> > > > > Regards,
> > > > >
> > > > > - Luis Cappa.
> > > > > El 18/11/2012 15:15, "Indika Tantrigoda" <in...@gmail.com>
> > > escribió:
> > > > >
> > > > > > Hi All,
> > > > > >
> > > > > > I would like to get results of an query that is different from
> the
> > > main
> > > > > > query as a new field. This query needs to be independent from any
> > > > filter
> > > > > > queries applied to the main query. I was trying to achieve this
> by
> > > > > > fl=_external_query_result:query($myQuery), however that result
> > seems
> > > to
> > > > > be
> > > > > > governed by any filter queries applied to the main query ? Is it
> > > > possible
> > > > > > to have a completely separate query in the fl list and return its
> > > > result
> > > > > > along with the results (per results), or would I need to create a
> > > > > separate
> > > > > > query on the client side to get the results of the independent
> > query
> > > > > (based
> > > > > > on the results from the first query) ?
> > > > > >
> > > > > > Thanks in advance,
> > > > > > Indika
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Execute an independent query from the main query

Posted by Otis Gospodnetic <ot...@gmail.com>.
Hi Indika,

So my suggestion was to maybe consider changing the index structure and
pull open/close times into 1 or more fields in the main record, so you
don't have this problem all together.

Otis
--
Performance Monitoring - http://sematext.com/spm/index.html
Search Analytics - http://sematext.com/search-analytics/index.html




On Sun, Nov 18, 2012 at 10:39 PM, Indika Tantrigoda <in...@gmail.com>wrote:

> Hi Otis,
>
> Actually I maintain a separate document for each open/close time along with
> the date (i.e. Sunday =1, Monday =2). I was thinking if it would be
> possible to query Solr asking, give the next day's (can be current_day +1)
> minimum opening time as a response field.
>
> Thanks,
> Indika
>
> On 19 November 2012 04:50, Otis Gospodnetic <otis.gospodnetic@gmail.com
> >wrote:
>
> > Hi,
> >
> > Maybe your index needs to have a separate field for each day open/close
> > time. No join or extra query needed then.
> >
> > Otis
> > --
> > Performance Monitoring - http://sematext.com/spm
> > On Nov 18, 2012 5:35 PM, "Indika Tantrigoda" <in...@gmail.com> wrote:
> >
> > > Thanks for the response.
> > >
> > > Erick,
> > > My use case is related to restaurant opening hours, In the same request
> > to
> > > Solr I'd like to get the time when the restaurant opens the next
> > > day, preferably part of the fields returned, and this needs to be
> > > independent of the main queries search params.
> > >
> > > Yes, the Join wouldn't be suitable in this use case.
> > >
> > > Luis,
> > > I had thought of having the logic in the client side, but before that I
> > > wanted to see if I could get the result from Solr itself. I
> > > am currently using SolrJ along with Spring.
> > >
> > > Thanks,
> > > Indika
> > >
> > > On 18 November 2012 21:49, Luis Cappa Banda <lu...@gmail.com>
> wrote:
> > >
> > > > Hello!
> > > >
> > > > When queries become more and more complex and you need to apply one
> > > second
> > > > query with the resultant docs from the first one, or re-sort results,
> > or
> > > > maybe add some promotional or special docs to the response, I
> recommend
> > > to
> > > > develop a Web App module that implements that complex business logic
> > and
> > > > dispatches queries from your Client App to your Solr back-end. That
> > > module,
> > > > let's call Search Engine, lets you play with all those special use
> > cases.
> > > > If you are familiar with Java I suggest you to have a look at the
> > > > combination between SolrJ and Spring framework or Jersey.
> > > >
> > > > Regards,
> > > >
> > > > - Luis Cappa.
> > > > El 18/11/2012 15:15, "Indika Tantrigoda" <in...@gmail.com>
> > escribió:
> > > >
> > > > > Hi All,
> > > > >
> > > > > I would like to get results of an query that is different from the
> > main
> > > > > query as a new field. This query needs to be independent from any
> > > filter
> > > > > queries applied to the main query. I was trying to achieve this by
> > > > > fl=_external_query_result:query($myQuery), however that result
> seems
> > to
> > > > be
> > > > > governed by any filter queries applied to the main query ? Is it
> > > possible
> > > > > to have a completely separate query in the fl list and return its
> > > result
> > > > > along with the results (per results), or would I need to create a
> > > > separate
> > > > > query on the client side to get the results of the independent
> query
> > > > (based
> > > > > on the results from the first query) ?
> > > > >
> > > > > Thanks in advance,
> > > > > Indika
> > > > >
> > > >
> > >
> >
>

Re: Execute an independent query from the main query

Posted by Indika Tantrigoda <in...@gmail.com>.
Hi Otis,

Actually I maintain a separate document for each open/close time along with
the date (i.e. Sunday =1, Monday =2). I was thinking if it would be
possible to query Solr asking, give the next day's (can be current_day +1)
minimum opening time as a response field.

Thanks,
Indika

On 19 November 2012 04:50, Otis Gospodnetic <ot...@gmail.com>wrote:

> Hi,
>
> Maybe your index needs to have a separate field for each day open/close
> time. No join or extra query needed then.
>
> Otis
> --
> Performance Monitoring - http://sematext.com/spm
> On Nov 18, 2012 5:35 PM, "Indika Tantrigoda" <in...@gmail.com> wrote:
>
> > Thanks for the response.
> >
> > Erick,
> > My use case is related to restaurant opening hours, In the same request
> to
> > Solr I'd like to get the time when the restaurant opens the next
> > day, preferably part of the fields returned, and this needs to be
> > independent of the main queries search params.
> >
> > Yes, the Join wouldn't be suitable in this use case.
> >
> > Luis,
> > I had thought of having the logic in the client side, but before that I
> > wanted to see if I could get the result from Solr itself. I
> > am currently using SolrJ along with Spring.
> >
> > Thanks,
> > Indika
> >
> > On 18 November 2012 21:49, Luis Cappa Banda <lu...@gmail.com> wrote:
> >
> > > Hello!
> > >
> > > When queries become more and more complex and you need to apply one
> > second
> > > query with the resultant docs from the first one, or re-sort results,
> or
> > > maybe add some promotional or special docs to the response, I recommend
> > to
> > > develop a Web App module that implements that complex business logic
> and
> > > dispatches queries from your Client App to your Solr back-end. That
> > module,
> > > let's call Search Engine, lets you play with all those special use
> cases.
> > > If you are familiar with Java I suggest you to have a look at the
> > > combination between SolrJ and Spring framework or Jersey.
> > >
> > > Regards,
> > >
> > > - Luis Cappa.
> > > El 18/11/2012 15:15, "Indika Tantrigoda" <in...@gmail.com>
> escribió:
> > >
> > > > Hi All,
> > > >
> > > > I would like to get results of an query that is different from the
> main
> > > > query as a new field. This query needs to be independent from any
> > filter
> > > > queries applied to the main query. I was trying to achieve this by
> > > > fl=_external_query_result:query($myQuery), however that result seems
> to
> > > be
> > > > governed by any filter queries applied to the main query ? Is it
> > possible
> > > > to have a completely separate query in the fl list and return its
> > result
> > > > along with the results (per results), or would I need to create a
> > > separate
> > > > query on the client side to get the results of the independent query
> > > (based
> > > > on the results from the first query) ?
> > > >
> > > > Thanks in advance,
> > > > Indika
> > > >
> > >
> >
>

Re: Execute an independent query from the main query

Posted by Otis Gospodnetic <ot...@gmail.com>.
Hi,

Maybe your index needs to have a separate field for each day open/close
time. No join or extra query needed then.

Otis
--
Performance Monitoring - http://sematext.com/spm
On Nov 18, 2012 5:35 PM, "Indika Tantrigoda" <in...@gmail.com> wrote:

> Thanks for the response.
>
> Erick,
> My use case is related to restaurant opening hours, In the same request to
> Solr I'd like to get the time when the restaurant opens the next
> day, preferably part of the fields returned, and this needs to be
> independent of the main queries search params.
>
> Yes, the Join wouldn't be suitable in this use case.
>
> Luis,
> I had thought of having the logic in the client side, but before that I
> wanted to see if I could get the result from Solr itself. I
> am currently using SolrJ along with Spring.
>
> Thanks,
> Indika
>
> On 18 November 2012 21:49, Luis Cappa Banda <lu...@gmail.com> wrote:
>
> > Hello!
> >
> > When queries become more and more complex and you need to apply one
> second
> > query with the resultant docs from the first one, or re-sort results, or
> > maybe add some promotional or special docs to the response, I recommend
> to
> > develop a Web App module that implements that complex business logic and
> > dispatches queries from your Client App to your Solr back-end. That
> module,
> > let's call Search Engine, lets you play with all those special use cases.
> > If you are familiar with Java I suggest you to have a look at the
> > combination between SolrJ and Spring framework or Jersey.
> >
> > Regards,
> >
> > - Luis Cappa.
> > El 18/11/2012 15:15, "Indika Tantrigoda" <in...@gmail.com> escribió:
> >
> > > Hi All,
> > >
> > > I would like to get results of an query that is different from the main
> > > query as a new field. This query needs to be independent from any
> filter
> > > queries applied to the main query. I was trying to achieve this by
> > > fl=_external_query_result:query($myQuery), however that result seems to
> > be
> > > governed by any filter queries applied to the main query ? Is it
> possible
> > > to have a completely separate query in the fl list and return its
> result
> > > along with the results (per results), or would I need to create a
> > separate
> > > query on the client side to get the results of the independent query
> > (based
> > > on the results from the first query) ?
> > >
> > > Thanks in advance,
> > > Indika
> > >
> >
>

Re: Execute an independent query from the main query

Posted by Indika Tantrigoda <in...@gmail.com>.
Thanks for the response.

Erick,
My use case is related to restaurant opening hours, In the same request to
Solr I'd like to get the time when the restaurant opens the next
day, preferably part of the fields returned, and this needs to be
independent of the main queries search params.

Yes, the Join wouldn't be suitable in this use case.

Luis,
I had thought of having the logic in the client side, but before that I
wanted to see if I could get the result from Solr itself. I
am currently using SolrJ along with Spring.

Thanks,
Indika

On 18 November 2012 21:49, Luis Cappa Banda <lu...@gmail.com> wrote:

> Hello!
>
> When queries become more and more complex and you need to apply one second
> query with the resultant docs from the first one, or re-sort results, or
> maybe add some promotional or special docs to the response, I recommend to
> develop a Web App module that implements that complex business logic and
> dispatches queries from your Client App to your Solr back-end. That module,
> let's call Search Engine, lets you play with all those special use cases.
> If you are familiar with Java I suggest you to have a look at the
> combination between SolrJ and Spring framework or Jersey.
>
> Regards,
>
> - Luis Cappa.
> El 18/11/2012 15:15, "Indika Tantrigoda" <in...@gmail.com> escribió:
>
> > Hi All,
> >
> > I would like to get results of an query that is different from the main
> > query as a new field. This query needs to be independent from any filter
> > queries applied to the main query. I was trying to achieve this by
> > fl=_external_query_result:query($myQuery), however that result seems to
> be
> > governed by any filter queries applied to the main query ? Is it possible
> > to have a completely separate query in the fl list and return its result
> > along with the results (per results), or would I need to create a
> separate
> > query on the client side to get the results of the independent query
> (based
> > on the results from the first query) ?
> >
> > Thanks in advance,
> > Indika
> >
>

Re: Execute an independent query from the main query

Posted by Luis Cappa Banda <lu...@gmail.com>.
Hello!

When queries become more and more complex and you need to apply one second
query with the resultant docs from the first one, or re-sort results, or
maybe add some promotional or special docs to the response, I recommend to
develop a Web App module that implements that complex business logic and
dispatches queries from your Client App to your Solr back-end. That module,
let's call Search Engine, lets you play with all those special use cases.
If you are familiar with Java I suggest you to have a look at the
combination between SolrJ and Spring framework or Jersey.

Regards,

- Luis Cappa.
El 18/11/2012 15:15, "Indika Tantrigoda" <in...@gmail.com> escribió:

> Hi All,
>
> I would like to get results of an query that is different from the main
> query as a new field. This query needs to be independent from any filter
> queries applied to the main query. I was trying to achieve this by
> fl=_external_query_result:query($myQuery), however that result seems to be
> governed by any filter queries applied to the main query ? Is it possible
> to have a completely separate query in the fl list and return its result
> along with the results (per results), or would I need to create a separate
> query on the client side to get the results of the independent query (based
> on the results from the first query) ?
>
> Thanks in advance,
> Indika
>

Re: Execute an independent query from the main query

Posted by Erick Erickson <er...@gmail.com>.
Depending on your use-case, you might be able to use the join
functionality. Be aware that this doesn't return the values of the
"from" field, so it may not be suitable.

_why_ do you want to do this? I'm wondering if this is an _XY_
problem.

Best,
Erick


On Sun, Nov 18, 2012 at 9:14 AM, Indika Tantrigoda <in...@gmail.com>wrote:

> Hi All,
>
> I would like to get results of an query that is different from the main
> query as a new field. This query needs to be independent from any filter
> queries applied to the main query. I was trying to achieve this by
> fl=_external_query_result:query($myQuery), however that result seems to be
> governed by any filter queries applied to the main query ? Is it possible
> to have a completely separate query in the fl list and return its result
> along with the results (per results), or would I need to create a separate
> query on the client side to get the results of the independent query (based
> on the results from the first query) ?
>
> Thanks in advance,
> Indika
>