lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: FunctionQuery result field in SearchComponent code ?
Date Wed, 17 Jul 2013 17:09:54 GMT

The "freq" psuedo-field you are seeing in your example query is coming 
from a DocTransformer that is decorating the documents as part of the 
QueryResponseWriter phase -- this is happening much later then any of the 
SearchComponents that are executed.

If you wnat the same information in a SearchComponent you need to execute 
the underlying functionality yourself using the docid (no need to fetch 
the Document from the Searcher).

You could either construct & use an instance of TermFreqValueSource class 
as is, and ask it for each docid in your DocList, or you could peek under 
the covers and just take the bits of TermFreqValueSource that you need and 
use them directly in your custom class.

In general though: i'm not sure that the effort you are looking at is 
really worth the payoff of doing this logic in a SearchCOmponent -- you're 
only going ot be getting the sum of the the termfreq for the N documents 
included in teh response (ie: the rows param) which would be even easier 
to sum up in your client code as it would be on the server side.



: Date: Mon, 15 Jul 2013 16:01:57 +0500
: From: Tony Mullins <tonymullins.tm@gmail.com>
: Reply-To: dev@lucene.apache.org
: To: dev@lucene.apache.org
: Subject: FunctionQuery result field in SearchComponent code ?
: 
: Hi ,
: 
: I have written my custom Solr 4.3.0 SearchComponent and purpose of this
: component is to sum the result of FunctionQuery (termfreq) of some term of
: each doc and them embed the result in final output.
: 
: This is my query:
: 
: http://localhost:8080/solr/collection2/demoendpoint?q=spider&wt=xml&indent=true&fl=*,freq:termfreq%28product,%27spider%27%29
: 
: This is sample result doc on browser:
: 
: <doc><str name="id">11</str><str name="type">Video Games</str><str
: name="format">xbox 360</str><str name="product">The Amazing
: Spider-Man</str><int name="popularity">11</int><long
: name="_version_">1439994081345273856</long><int name="freq">1</int></doc>
: 
: 
: Here is my code from SearchComponent
: 
: DocList docs = rb.getResults().docList;
:         DocIterator iterator = docs.iterator();
:         int sumFreq = 0;
:         String id = null;
: 
:         for (int i = 0; i < docs.size(); i++) {
:             try {
:                 int docId = iterator.nextDoc();
: 
:                // Document doc = searcher.doc(docId, fieldSet);
:                 Document doc = searcher.doc(docId);
: 
: In 'doc' object I can see the schema fields like 'id', 'type','format' etc.
: but I cannot find the field 'freq' which I needed.
: 
: Is there any way to get the FunctionQuery fields in doc object ?
: 
: Thanks,
: Tony
: 

-Hoss

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message