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 Osman İZBAT <oi...@gmail.com> on 2009/07/07 13:05:13 UTC
Can't limit return fields in custom request handler
Hi.
I'm writing my custom faceted request handler.
But I have a problem like this; when i call
http://localhost:8983/solr/select/?qt=cfacet&q=%2BitemTitle:nokia%20%2BcategoryId:130&start=0&limit=3&fl=id,
itemTitle
i'm getiing all fields instead of only id and itemTitle.
Also i'm gettting no result when i give none null filter parameter in
getDocListAndSet(...).
public class MyCustomFacetRequestHandler extends StandardRequestHandler {
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse
rsp) throws Exception {
try {
SolrParams solrParams = req.getParams();
Query q = QueryParsing.parseQuery(solrParams.get("q"),
req.getSchema());
DocListAndSet results = req.getSearcher().getDocListAndSet(q,
(Query)null, (Sort)null, solrParams.getInt("start"),
solrParams.getInt("limit"));
...
Regards.
--
Osman İZBAT
Re: Can't limit return fields in custom request handler
Posted by Osman İZBAT <oi...@gmail.com>.
Thank you very much Chris.
Regards.
On Mon, Jul 13, 2009 at 4:30 AM, Chris Hostetter
<ho...@fucit.org>wrote:
>
> : Query filter = new TermQuery(new Term("inStores", "true"));
>
> that will work if "inStores" is a TextField or a StrField and it's got the
> term "true" indexed in it ... but if it's a BoolField like in the
> example schema then the values that appear in the index are "T" and "F"
>
> When you write custom Solr plugins You *HAVE* to leverage the FieldType of
> fields you deal with when building queries programaticly. this is what
> the "FieldType.toInternal" method is for.
>
>
>
>
> -Hoss
>
>
--
Osman İZBAT
Re: Can't limit return fields in custom request handler
Posted by Chris Hostetter <ho...@fucit.org>.
: Query filter = new TermQuery(new Term("inStores", "true"));
that will work if "inStores" is a TextField or a StrField and it's got the
term "true" indexed in it ... but if it's a BoolField like in the
example schema then the values that appear in the index are "T" and "F"
When you write custom Solr plugins You *HAVE* to leverage the FieldType of
fields you deal with when building queries programaticly. this is what
the "FieldType.toInternal" method is for.
-Hoss
Re: Can't limit return fields in custom request handler
Posted by Osman İZBAT <oi...@gmail.com>.
II'll look SolrPluginUtils.setReturnFields.
I'm running same query :
http://localhost:8983/solr/select/?qt=cfacet&q=%2BitemTitle:nokia%20%2BcategoryId:130&start=0&limit=3<http://localhost:8983/solr/select/?qt=cfacet&q=%2BitemTitle:nokia%20%2BcategoryId:130&start=0&limit=3&fl=id>
I get none empty result when filter parameter is null, but when i pass
"inStores" filter parameter to getDocListAndSet i get empty result.
SolrParams solrParams = req.getParams();
Query q = QueryParsing.parseQuery(solrParams.get("q"),
req.getSchema());
Query filter = new TermQuery(new Term("inStores", "true"));
DocListAndSet results = req.getSearcher().getDocListAndSet(q,
(Query)filter, (Sort)null, solrParams.getInt("start"),
solrParams.getInt("limit"));
Thanks.
On Tue, Jul 7, 2009 at 11:45 PM, Chris Hostetter
<ho...@fucit.org>wrote:
>
> : But I have a problem like this; when i call
> :
> http://localhost:8983/solr/select/?qt=cfacet&q=%2BitemTitle:nokia%20%2BcategoryId:130&start=0&limit=3&fl=id
> ,
> : itemTitle
> : i'm getiing all fields instead of only id and itemTitle.
>
> Your custom handler is responsible for checking the fl and setting what
> you want the response fields to be on the response object.
>
> SolrPluginUtils.setReturnFields can be used if you want this to be done in
> the "normal" way.
>
> : Also i'm gettting no result when i give none null filter parameter in
> : getDocListAndSet(...).
> ...
> : DocListAndSet results = req.getSearcher().getDocListAndSet(q,
> : (Query)null, (Sort)null, solrParams.getInt("start"),
> : solrParams.getInt("limit"));
>
> ...that should work. What does your query look like? what are you
> passing for the "start" and "limit" params (is it possible you are getting
> results, but limit=0 so there aren't any results on the current page of
> pagination?) what does the debug output look like?
>
>
> -Hoss
>
>
--
Osman İZBAT
Re: Can't limit return fields in custom request handler
Posted by Chris Hostetter <ho...@fucit.org>.
: But I have a problem like this; when i call
: http://localhost:8983/solr/select/?qt=cfacet&q=%2BitemTitle:nokia%20%2BcategoryId:130&start=0&limit=3&fl=id,
: itemTitle
: i'm getiing all fields instead of only id and itemTitle.
Your custom handler is responsible for checking the fl and setting what
you want the response fields to be on the response object.
SolrPluginUtils.setReturnFields can be used if you want this to be done in
the "normal" way.
: Also i'm gettting no result when i give none null filter parameter in
: getDocListAndSet(...).
...
: DocListAndSet results = req.getSearcher().getDocListAndSet(q,
: (Query)null, (Sort)null, solrParams.getInt("start"),
: solrParams.getInt("limit"));
...that should work. What does your query look like? what are you
passing for the "start" and "limit" params (is it possible you are getting
results, but limit=0 so there aren't any results on the current page of
pagination?) what does the debug output look like?
-Hoss