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 Jason Toy <ja...@gmail.com> on 2011/06/09 15:23:27 UTC

how can I return function results in my query?

I want to be able to run a query  like idf(text, 'term') and have that data
returned with my search results.  I've searched the docs,but I'm unable to
find how to do it.  Is this possible and how can I do that ?

Re: how can I return function results in my query?

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Fri, Jun 10, 2011 at 8:31 AM, Markus Jelsma
<ma...@openindex.io> wrote:
> Nice! Will SOLR-1298 with aliasing also work with an external file field since
> that can be a source of a function query as well?

Haven't tried it, but it definitely should!

-Yonik
http://www.lucidimagination.com

Re: how can I return function results in my query?

Posted by Markus Jelsma <ma...@openindex.io>.
Nice! Will SOLR-1298 with aliasing also work with an external file field since 
that can be a source of a function query as well?

> On Thu, Jun 9, 2011 at 9:23 AM, Jason Toy <ja...@gmail.com> wrote:
> > I want to be able to run a query  like idf(text, 'term') and have that
> > data returned with my search results.  I've searched the docs,but I'm
> > unable to find how to do it.  Is this possible and how can I do that ?
> 
> In trunk, there's a very new feature called pseudo-fields where (among
> other things) you can include the results of arbitrary function
> queries along with the stored fields for each document.
> 
> fl=id,idf(text,'term'),termfreq(text,'term')
> 
> Or if you want to alias the idf call to a different name:
> 
> fl=id,myidf:idf(text,'term'),mytermfreq:termfreq(text,'term')
> 
> Of course, in this specific case it's a bit of a waste since idf won't
> change per document.
> 
> -Yonik
> http://www.lucidimagination.com

Re: how can I return function results in my query?

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Thu, Jun 9, 2011 at 9:23 AM, Jason Toy <ja...@gmail.com> wrote:
> I want to be able to run a query  like idf(text, 'term') and have that data
> returned with my search results.  I've searched the docs,but I'm unable to
> find how to do it.  Is this possible and how can I do that ?

In trunk, there's a very new feature called pseudo-fields where (among
other things) you can include the results of arbitrary function
queries along with the stored fields for each document.

fl=id,idf(text,'term'),termfreq(text,'term')

Or if you want to alias the idf call to a different name:

fl=id,myidf:idf(text,'term'),mytermfreq:termfreq(text,'term')

Of course, in this specific case it's a bit of a waste since idf won't
change per document.

-Yonik
http://www.lucidimagination.com

Re: how can I return function results in my query?

Posted by Markus Jelsma <ma...@openindex.io>.
Jason,

Solr cannot add results of functions to the resultset for now. I don't know 
about a ticket (but i'd think there is one) but it's also highly desired in 
returning distances in spatial queries. Check Jira if you need to know more.

Take care, debugQuery can add significant delay. If you need idf frequently 
then consider tvc. 

Cheers,

> Markus,
> Thanks for this info, I'll use debugQuery to test for now. It seems strange
> that I can't have  arbitrary function results returned with my data.  Is
> this an obstacle on the lucene or solr side?
> 
> Jason
> 
> On Fri, Jun 10, 2011 at 5:59 AM, Markus Jelsma
> 
> <ma...@openindex.io>wrote:
> > Ah, function results are not returned in the result set. You must either
> > use
> > debugQuery to get the value or the TermVectorComponent to get idf for
> > existing
> > terms.
> > 
> > > Ahmet, that doesnt return the idf data in my results, unless I am
> > > doing something wrong.  When you run any function you get the results
> > > of the function back?
> > > 
> > > Can you show me an example query you run ?
> > > 
> > > 
> > > 
> > > //http://wiki.apache.org/solr/FunctionQuery#idf
> > > 
> > > On Thu, Jun 9, 2011 at 9:23 AM, Jason Toy <ja...@gmail.com> wrote:
> > > > I want to be able to run a query  like idf(text, 'term') and have
> > > > that data returned with my search results.  I've searched the
> > > > docs,but I'm unable to find how to do it.  Is this possible and how
> > > > can I do that ?

Re: how can I return function results in my query?

Posted by Jason Toy <ja...@gmail.com>.
Markus,
Thanks for this info, I'll use debugQuery to test for now. It seems strange
that I can't have  arbitrary function results returned with my data.  Is
this an obstacle on the lucene or solr side?

Jason

On Fri, Jun 10, 2011 at 5:59 AM, Markus Jelsma
<ma...@openindex.io>wrote:

> Ah, function results are not returned in the result set. You must either
> use
> debugQuery to get the value or the TermVectorComponent to get idf for
> existing
> terms.
>
> > Ahmet, that doesnt return the idf data in my results, unless I am
> > doing something wrong.  When you run any function you get the results
> > of the function back?
> >
> > Can you show me an example query you run ?
> >
> >
> >
> > //http://wiki.apache.org/solr/FunctionQuery#idf
> >
> > On Thu, Jun 9, 2011 at 9:23 AM, Jason Toy <ja...@gmail.com> wrote:
> > > I want to be able to run a query  like idf(text, 'term') and have that
> > > data returned with my search results.  I've searched the docs,but I'm
> > > unable to find how to do it.  Is this possible and how can I do that ?
>



-- 
- sent from my mobile
6176064373

Re: how can I return function results in my query?

Posted by Markus Jelsma <ma...@openindex.io>.
Ah, function results are not returned in the result set. You must either use 
debugQuery to get the value or the TermVectorComponent to get idf for existing 
terms.

> Ahmet, that doesnt return the idf data in my results, unless I am
> doing something wrong.  When you run any function you get the results
> of the function back?
> 
> Can you show me an example query you run ?
> 
> 
> 
> //http://wiki.apache.org/solr/FunctionQuery#idf
> 
> On Thu, Jun 9, 2011 at 9:23 AM, Jason Toy <ja...@gmail.com> wrote:
> > I want to be able to run a query  like idf(text, 'term') and have that
> > data returned with my search results.  I've searched the docs,but I'm
> > unable to find how to do it.  Is this possible and how can I do that ?

Re: how can I return function results in my query?

Posted by Ahmet Arslan <io...@yahoo.com>.
> Ahmet, that doesnt return the idf
> data in my results, unless I am
> doing something wrong.  When you run any function you
> get the results
> of the function back?

I have never used Relevance Functions but there is an example [1] in the wiki where result of the function query is reflected into score. Then in order to get the computed function query it uses &fl=*,score.

[1] http://wiki.apache.org/solr/FunctionQuery#General_Example

Re: how can I return function results in my query?

Posted by Jason Toy <ja...@gmail.com>.
Ahmet, that doesnt return the idf data in my results, unless I am
doing something wrong.  When you run any function you get the results
of the function back?

Can you show me an example query you run ?



//http://wiki.apache.org/solr/FunctionQuery#idf



On Thu, Jun 9, 2011 at 9:23 AM, Jason Toy <ja...@gmail.com> wrote:

> I want to be able to run a query  like idf(text, 'term') and have that data
> returned with my search results.  I've searched the docs,but I'm unable to
> find how to do it.  Is this possible and how can I do that ?
>
>
>


-- 
- sent from my mobile
6176064373

Re: how can I return function results in my query?

Posted by Ahmet Arslan <io...@yahoo.com>.
> I want to be able to run a
> query  like idf(text, 'term') and have that data
> returned with my search results.  I've searched the
> docs,but I'm unable to
> find how to do it.  Is this possible and how can I do
> that ?

http://wiki.apache.org/solr/FunctionQuery#idf