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 Luis Cappa Banda <lu...@gmail.com> on 2013/05/14 10:55:28 UTC

Quick SolrJ query how-to question.

Hello, guys!

I would like to do something like this. Let's suppose we have:

*
*
*(...) *
*
*
*String query = "q=*:*&start=0&rows=20&sort=date%20desc";*
*
*
*SolrQuery solrQuery = new SolrQuery();*
*solrQuery.setQuery(query);*
*
*
*server.query(solrQuery);*
*
*
*(...)*



I tried that and it fails. My question is: is it possible to define a
SolrQuery with the complete REST encoded query String without parsing
manually all the query parameters and using SolrQuery methods to set them?

Regards,

-- 
- Luis Cappa

Re: Quick SolrJ query how-to question.

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

Of course that the part that parses the URL requests must be in Servlet
side. However, if the project is well modularized, that Java classes,
dependencies... whatever, could be re-used inside SolrJ project, so I don´t
think that it would be an enourmous extra work. That´s the magic of Softwre
development: reuse as much you can what you´ve done before. And of course
is cuestionable if it´s a good or a bad idea, and everyone should have his
opinion about it, but I just see advantages and not much extra work for
someone that have a good knowledge of Solr main source code project. That´s
not my case, :-(

What I´m doing right now is just a wrapper around Solr to implement a
custom solution for sharding, both distribute search and indexation
operations. I call it SolrCluster, and it´s a black box that from outside
is used as a simple Solr Server to execute REST queries or update
operations with almost the same syntax, managing Clusters of Solr servers
composed by Shards and checking continously each Cluster status. Of course,
SolrCloud exists and many people like it, but after using it in test,
development and also in one production environments I feel that it doesn´t
fit 100% my needs and that it needs some work to become stable.

In my SolrCluster implementation queries are execute this way:

http://localhost:880/solrcluster/{clusterName}/select?q=*:*&start=0&rows=20&wt=json.
..


Now you can understand why I think that it would be extremely useful,
powerful and flexible to not necesary bind queries into Java Objects and
just play around with String queries. Also, in the future Solr probably
should not be a Java Application to be deployed in a Application server,
because even these days it has no sense, so enabling a way to execute
queries with old fashioned String style from SolrJ would be one task to do
in that roadmap. Who knows.

The same happens with updates operations, where you POST new data to be
indexed:

http://localhost:880/solrcluster/{clusterName}/update


So that´s why I´m asking for all this stuff, :-)

Regards,



2013/5/14 Jack Park <ja...@topicquests.org>

> In some sense, if all you want to do is send over a URL, e.g.
> http://localhost:8993/<some stuff>, it's not out of the question to
> use the java url stuff as exemplified at
> http://www.cafeaulait.org/course/week12/22.html
> or
>
> http://stackoverflow.com/questions/7500342/using-sockets-to-fetch-a-webpage-with-java
>
> But, that's a trivial case. You might have something else in mind.
>
> Jack
>
> On Tue, May 14, 2013 at 1:36 PM, Shawn Heisey <so...@elyograg.org> wrote:
> > On 5/14/2013 3:13 AM, Luis Cappa Banda wrote:
> >> I know that, but I was wondering if it exists another way just to set
> the
> >> complete query (including q, fq, sort, etc.) embedded in a SolrQuery
> object
> >> as the same way that you query using some kind of RequestHandler. That
> way
> >> would be more flexible because you don't need to parse the complete
> query
> >> checking q, fg, sort... parameters one by one and setting them with
> >> setFields(), setStart(), setRows(), etcetera. Solr is doing that query
> >> parse internally when you execute queries with it's REST API and maybe
> >> there exist a way to re-use that functionality to just set a String to a
> >> SolrQuery and that SolrQuery does internally all the magic.
> >
> > This is a little bit of an odd idea, because it goes against the way a
> > Java programmer expects to do things.  Where does the 'URL parameter'
> > version of your query come from?  If it's possible, it would make more
> > sense to incorporate that code into your SolrJ app and avoid two steps
> > -- the need to create the URL syntax and the need to decode the URL
> syntax.
> >
> > In a later message, you said that you are working on a SolrServer
> > implementation to handle your use case.  I'm wondering if SolrJ already
> > has URL query parameter parsing capability.  I'd be slightly surprised
> > to learn that it does - that code is probably part of the servlet API.
> >
> > It's not that your idea is bad, it just sounds like a ton of extra work
> > that could be better spent elsewhere.
> >
> > Thanks,
> > Shawn
> >
>



-- 
- Luis Cappa

Re: Quick SolrJ query how-to question.

Posted by Jack Park <ja...@topicquests.org>.
In some sense, if all you want to do is send over a URL, e.g.
http://localhost:8993/<some stuff>, it's not out of the question to
use the java url stuff as exemplified at
http://www.cafeaulait.org/course/week12/22.html
or
http://stackoverflow.com/questions/7500342/using-sockets-to-fetch-a-webpage-with-java

But, that's a trivial case. You might have something else in mind.

Jack

On Tue, May 14, 2013 at 1:36 PM, Shawn Heisey <so...@elyograg.org> wrote:
> On 5/14/2013 3:13 AM, Luis Cappa Banda wrote:
>> I know that, but I was wondering if it exists another way just to set the
>> complete query (including q, fq, sort, etc.) embedded in a SolrQuery object
>> as the same way that you query using some kind of RequestHandler. That way
>> would be more flexible because you don't need to parse the complete query
>> checking q, fg, sort... parameters one by one and setting them with
>> setFields(), setStart(), setRows(), etcetera. Solr is doing that query
>> parse internally when you execute queries with it's REST API and maybe
>> there exist a way to re-use that functionality to just set a String to a
>> SolrQuery and that SolrQuery does internally all the magic.
>
> This is a little bit of an odd idea, because it goes against the way a
> Java programmer expects to do things.  Where does the 'URL parameter'
> version of your query come from?  If it's possible, it would make more
> sense to incorporate that code into your SolrJ app and avoid two steps
> -- the need to create the URL syntax and the need to decode the URL syntax.
>
> In a later message, you said that you are working on a SolrServer
> implementation to handle your use case.  I'm wondering if SolrJ already
> has URL query parameter parsing capability.  I'd be slightly surprised
> to learn that it does - that code is probably part of the servlet API.
>
> It's not that your idea is bad, it just sounds like a ton of extra work
> that could be better spent elsewhere.
>
> Thanks,
> Shawn
>

Re: Quick SolrJ query how-to question.

Posted by Shawn Heisey <so...@elyograg.org>.
On 5/14/2013 3:13 AM, Luis Cappa Banda wrote:
> I know that, but I was wondering if it exists another way just to set the
> complete query (including q, fq, sort, etc.) embedded in a SolrQuery object
> as the same way that you query using some kind of RequestHandler. That way
> would be more flexible because you don't need to parse the complete query
> checking q, fg, sort... parameters one by one and setting them with
> setFields(), setStart(), setRows(), etcetera. Solr is doing that query
> parse internally when you execute queries with it's REST API and maybe
> there exist a way to re-use that functionality to just set a String to a
> SolrQuery and that SolrQuery does internally all the magic.

This is a little bit of an odd idea, because it goes against the way a
Java programmer expects to do things.  Where does the 'URL parameter'
version of your query come from?  If it's possible, it would make more
sense to incorporate that code into your SolrJ app and avoid two steps
-- the need to create the URL syntax and the need to decode the URL syntax.

In a later message, you said that you are working on a SolrServer
implementation to handle your use case.  I'm wondering if SolrJ already
has URL query parameter parsing capability.  I'd be slightly surprised
to learn that it does - that code is probably part of the servlet API.

It's not that your idea is bad, it just sounds like a ton of extra work
that could be better spent elsewhere.

Thanks,
Shawn


Re: Quick SolrJ query how-to question.

Posted by Luis Cappa Banda <lu...@gmail.com>.
Hey, hello!

Which class or classes do you suggest to check out it's source code?

Thank you,


2013/5/14 Upayavira <uv...@odoko.co.uk>

> Look at the source code for SolrJ, you'll find it is just a glorified
> HashMap, and you might find a way to interact with it that suits you (I
> think the end URL is just the result of calling toString() on the
> HashMap).
>
> Upayavira
>
> On Tue, May 14, 2013, at 10:13 AM, Luis Cappa Banda wrote:
> > I know that, but I was wondering if it exists another way just to set the
> > complete query (including q, fq, sort, etc.) embedded in a SolrQuery
> > object
> > as the same way that you query using some kind of RequestHandler. That
> > way
> > would be more flexible because you don't need to parse the complete query
> > checking q, fg, sort... parameters one by one and setting them with
> > setFields(), setStart(), setRows(), etcetera. Solr is doing that query
> > parse internally when you execute queries with it's REST API and maybe
> > there exist a way to re-use that functionality to just set a String to a
> > SolrQuery and that SolrQuery does internally all the magic.
> >
> > Thanks in advance,
> >
> >
> > 2013/5/14 Jienan Duan <jn...@gmail.com>
> >
> > > hi,
> > > the solrQuery.setQuery() method just set the 'q' param in the query
> string.
> > > You need call other method to set up all necessary param:
> > > solrQuery.setFields(); --> this set up the 'fl' param
> > > solrQuery.setStart(); --> this set up the 'start' param
> > > solrQuery.setRows(); --> this set up the 'rows' param
> > > solrQuery.setSort();  --> this set up the 'sort'param
> > >
> > > You can look into
> > >
> > >
> http://lucene.apache.org/solr/4_2_1/solr-solrj/org/apache/solr/client/solrj/SolrQuery.htmlto
> > > see more details about SolrQuery.
> > >
> > >
> > > 2013/5/14 Luis Cappa Banda <lu...@gmail.com>
> > >
> > > > Hello, guys!
> > > >
> > > > I would like to do something like this. Let's suppose we have:
> > > >
> > > > *
> > > > *
> > > > *(...) *
> > > > *
> > > > *
> > > > *String query = "q=*:*&start=0&rows=20&sort=date%20desc";*
> > > > *
> > > > *
> > > > *SolrQuery solrQuery = new SolrQuery();*
> > > > *solrQuery.setQuery(query);*
> > > > *
> > > > *
> > > > *server.query(solrQuery);*
> > > > *
> > > > *
> > > > *(...)*
> > > >
> > > >
> > > >
> > > > I tried that and it fails. My question is: is it possible to define a
> > > > SolrQuery with the complete REST encoded query String without parsing
> > > > manually all the query parameters and using SolrQuery methods to set
> > > them?
> > > >
> > > > Regards,
> > > >
> > > > --
> > > > - Luis Cappa
> > > >
> > >
> > >
> > >
> > > --
> > > ------------------------------------------------------
> > > 不走弯路,就是捷径。
> > > http://www.jnan.org/
> > >
> >
> >
> >
> > --
> > - Luis Cappa
>



-- 
- Luis Cappa

Re: Quick SolrJ query how-to question.

Posted by Upayavira <uv...@odoko.co.uk>.
Look at the source code for SolrJ, you'll find it is just a glorified
HashMap, and you might find a way to interact with it that suits you (I
think the end URL is just the result of calling toString() on the
HashMap).

Upayavira

On Tue, May 14, 2013, at 10:13 AM, Luis Cappa Banda wrote:
> I know that, but I was wondering if it exists another way just to set the
> complete query (including q, fq, sort, etc.) embedded in a SolrQuery
> object
> as the same way that you query using some kind of RequestHandler. That
> way
> would be more flexible because you don't need to parse the complete query
> checking q, fg, sort... parameters one by one and setting them with
> setFields(), setStart(), setRows(), etcetera. Solr is doing that query
> parse internally when you execute queries with it's REST API and maybe
> there exist a way to re-use that functionality to just set a String to a
> SolrQuery and that SolrQuery does internally all the magic.
> 
> Thanks in advance,
> 
> 
> 2013/5/14 Jienan Duan <jn...@gmail.com>
> 
> > hi,
> > the solrQuery.setQuery() method just set the 'q' param in the query string.
> > You need call other method to set up all necessary param:
> > solrQuery.setFields(); --> this set up the 'fl' param
> > solrQuery.setStart(); --> this set up the 'start' param
> > solrQuery.setRows(); --> this set up the 'rows' param
> > solrQuery.setSort();  --> this set up the 'sort'param
> >
> > You can look into
> >
> > http://lucene.apache.org/solr/4_2_1/solr-solrj/org/apache/solr/client/solrj/SolrQuery.htmlto
> > see more details about SolrQuery.
> >
> >
> > 2013/5/14 Luis Cappa Banda <lu...@gmail.com>
> >
> > > Hello, guys!
> > >
> > > I would like to do something like this. Let's suppose we have:
> > >
> > > *
> > > *
> > > *(...) *
> > > *
> > > *
> > > *String query = "q=*:*&start=0&rows=20&sort=date%20desc";*
> > > *
> > > *
> > > *SolrQuery solrQuery = new SolrQuery();*
> > > *solrQuery.setQuery(query);*
> > > *
> > > *
> > > *server.query(solrQuery);*
> > > *
> > > *
> > > *(...)*
> > >
> > >
> > >
> > > I tried that and it fails. My question is: is it possible to define a
> > > SolrQuery with the complete REST encoded query String without parsing
> > > manually all the query parameters and using SolrQuery methods to set
> > them?
> > >
> > > Regards,
> > >
> > > --
> > > - Luis Cappa
> > >
> >
> >
> >
> > --
> > ------------------------------------------------------
> > 不走弯路,就是捷径。
> > http://www.jnan.org/
> >
> 
> 
> 
> -- 
> - Luis Cappa

Re: Quick SolrJ query how-to question.

Posted by Luis Cappa Banda <lu...@gmail.com>.
I'm developing a custom SolrServer that executes raw queries. Those raw
queries are the ones I mentioned before: String ones. The idea is that that
custom SolrServer execute internally the raw String query via HttpClient
(GET or POST) and then returns a QueryResponse. I want to be respectful
with SolrJ classes, but as you can imagine is hard (almost imposible) to
map that JSON into a QueryResponse class instance. Currently I'm returning
a simple String as the final response, which is a JSON itself.


2013/5/14 Jienan Duan <jn...@gmail.com>

> Why are you parsing te response to a QueryResponse object? I think it's
> much easier to parse a json format response to you business object.
>
>
> 2013/5/14 Luis Cappa Banda <lu...@gmail.com>
>
> > Yeah, unfortunately that's what I'm doing right now, but parsing the
> > resultant String from the HttpClient response into a QueryResponse seems
> to
> > be imposible... I think that this would be a great feature to include in
> > next Solr release. I'm sure that many people will find useful to execute
> > raw String queries with SolrQuery instead setting manually that query
> into
> > SolrQuery with the setters methods defined.
> >
> > Regards,
> >
> >
> >
> > 2013/5/14 Jienan Duan <jn...@gmail.com>
> >
> > > I don't see any method in SolrServer like what you want.But I think you
> > > just need write some code with HttpClient ,make a http request use the
> > > complete query string.
> > >
> > > 2013/5/14 Luis Cappa Banda <lu...@gmail.com>
> > >
> > > > I know that, but I was wondering if it exists another way just to set
> > the
> > > > complete query (including q, fq, sort, etc.) embedded in a SolrQuery
> > > object
> > > > as the same way that you query using some kind of RequestHandler.
> That
> > > way
> > > > would be more flexible because you don't need to parse the complete
> > query
> > > > checking q, fg, sort... parameters one by one and setting them with
> > > > setFields(), setStart(), setRows(), etcetera. Solr is doing that
> query
> > > > parse internally when you execute queries with it's REST API and
> maybe
> > > > there exist a way to re-use that functionality to just set a String
> to
> > a
> > > > SolrQuery and that SolrQuery does internally all the magic.
> > > >
> > > > Thanks in advance,
> > > >
> > > >
> > > > 2013/5/14 Jienan Duan <jn...@gmail.com>
> > > >
> > > > > hi,
> > > > > the solrQuery.setQuery() method just set the 'q' param in the query
> > > > string.
> > > > > You need call other method to set up all necessary param:
> > > > > solrQuery.setFields(); --> this set up the 'fl' param
> > > > > solrQuery.setStart(); --> this set up the 'start' param
> > > > > solrQuery.setRows(); --> this set up the 'rows' param
> > > > > solrQuery.setSort();  --> this set up the 'sort'param
> > > > >
> > > > > You can look into
> > > > >
> > > > >
> > > >
> > >
> >
> http://lucene.apache.org/solr/4_2_1/solr-solrj/org/apache/solr/client/solrj/SolrQuery.htmlto
> > > > > see more details about SolrQuery.
> > > > >
> > > > >
> > > > > 2013/5/14 Luis Cappa Banda <lu...@gmail.com>
> > > > >
> > > > > > Hello, guys!
> > > > > >
> > > > > > I would like to do something like this. Let's suppose we have:
> > > > > >
> > > > > > *
> > > > > > *
> > > > > > *(...) *
> > > > > > *
> > > > > > *
> > > > > > *String query = "q=*:*&start=0&rows=20&sort=date%20desc";*
> > > > > > *
> > > > > > *
> > > > > > *SolrQuery solrQuery = new SolrQuery();*
> > > > > > *solrQuery.setQuery(query);*
> > > > > > *
> > > > > > *
> > > > > > *server.query(solrQuery);*
> > > > > > *
> > > > > > *
> > > > > > *(...)*
> > > > > >
> > > > > >
> > > > > >
> > > > > > I tried that and it fails. My question is: is it possible to
> > define a
> > > > > > SolrQuery with the complete REST encoded query String without
> > parsing
> > > > > > manually all the query parameters and using SolrQuery methods to
> > set
> > > > > them?
> > > > > >
> > > > > > Regards,
> > > > > >
> > > > > > --
> > > > > > - Luis Cappa
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > ------------------------------------------------------
> > > > > 不走弯路,就是捷径。
> > > > > http://www.jnan.org/
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > - Luis Cappa
> > > >
> > >
> > >
> > >
> > > --
> > > ------------------------------------------------------
> > > 不走弯路,就是捷径。
> > > http://www.jnan.org/
> > >
> >
> >
> >
> > --
> > - Luis Cappa
> >
>
>
>
> --
> ------------------------------------------------------
> 不走弯路,就是捷径。
> http://www.jnan.org/
>



-- 
- Luis Cappa

Re: Quick SolrJ query how-to question.

Posted by Jienan Duan <jn...@gmail.com>.
Why are you parsing te response to a QueryResponse object? I think it's
much easier to parse a json format response to you business object.


2013/5/14 Luis Cappa Banda <lu...@gmail.com>

> Yeah, unfortunately that's what I'm doing right now, but parsing the
> resultant String from the HttpClient response into a QueryResponse seems to
> be imposible... I think that this would be a great feature to include in
> next Solr release. I'm sure that many people will find useful to execute
> raw String queries with SolrQuery instead setting manually that query into
> SolrQuery with the setters methods defined.
>
> Regards,
>
>
>
> 2013/5/14 Jienan Duan <jn...@gmail.com>
>
> > I don't see any method in SolrServer like what you want.But I think you
> > just need write some code with HttpClient ,make a http request use the
> > complete query string.
> >
> > 2013/5/14 Luis Cappa Banda <lu...@gmail.com>
> >
> > > I know that, but I was wondering if it exists another way just to set
> the
> > > complete query (including q, fq, sort, etc.) embedded in a SolrQuery
> > object
> > > as the same way that you query using some kind of RequestHandler. That
> > way
> > > would be more flexible because you don't need to parse the complete
> query
> > > checking q, fg, sort... parameters one by one and setting them with
> > > setFields(), setStart(), setRows(), etcetera. Solr is doing that query
> > > parse internally when you execute queries with it's REST API and maybe
> > > there exist a way to re-use that functionality to just set a String to
> a
> > > SolrQuery and that SolrQuery does internally all the magic.
> > >
> > > Thanks in advance,
> > >
> > >
> > > 2013/5/14 Jienan Duan <jn...@gmail.com>
> > >
> > > > hi,
> > > > the solrQuery.setQuery() method just set the 'q' param in the query
> > > string.
> > > > You need call other method to set up all necessary param:
> > > > solrQuery.setFields(); --> this set up the 'fl' param
> > > > solrQuery.setStart(); --> this set up the 'start' param
> > > > solrQuery.setRows(); --> this set up the 'rows' param
> > > > solrQuery.setSort();  --> this set up the 'sort'param
> > > >
> > > > You can look into
> > > >
> > > >
> > >
> >
> http://lucene.apache.org/solr/4_2_1/solr-solrj/org/apache/solr/client/solrj/SolrQuery.htmlto
> > > > see more details about SolrQuery.
> > > >
> > > >
> > > > 2013/5/14 Luis Cappa Banda <lu...@gmail.com>
> > > >
> > > > > Hello, guys!
> > > > >
> > > > > I would like to do something like this. Let's suppose we have:
> > > > >
> > > > > *
> > > > > *
> > > > > *(...) *
> > > > > *
> > > > > *
> > > > > *String query = "q=*:*&start=0&rows=20&sort=date%20desc";*
> > > > > *
> > > > > *
> > > > > *SolrQuery solrQuery = new SolrQuery();*
> > > > > *solrQuery.setQuery(query);*
> > > > > *
> > > > > *
> > > > > *server.query(solrQuery);*
> > > > > *
> > > > > *
> > > > > *(...)*
> > > > >
> > > > >
> > > > >
> > > > > I tried that and it fails. My question is: is it possible to
> define a
> > > > > SolrQuery with the complete REST encoded query String without
> parsing
> > > > > manually all the query parameters and using SolrQuery methods to
> set
> > > > them?
> > > > >
> > > > > Regards,
> > > > >
> > > > > --
> > > > > - Luis Cappa
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > ------------------------------------------------------
> > > > 不走弯路,就是捷径。
> > > > http://www.jnan.org/
> > > >
> > >
> > >
> > >
> > > --
> > > - Luis Cappa
> > >
> >
> >
> >
> > --
> > ------------------------------------------------------
> > 不走弯路,就是捷径。
> > http://www.jnan.org/
> >
>
>
>
> --
> - Luis Cappa
>



-- 
------------------------------------------------------
不走弯路,就是捷径。
http://www.jnan.org/

Re: Quick SolrJ query how-to question.

Posted by Luis Cappa Banda <lu...@gmail.com>.
Yeah, unfortunately that's what I'm doing right now, but parsing the
resultant String from the HttpClient response into a QueryResponse seems to
be imposible... I think that this would be a great feature to include in
next Solr release. I'm sure that many people will find useful to execute
raw String queries with SolrQuery instead setting manually that query into
SolrQuery with the setters methods defined.

Regards,



2013/5/14 Jienan Duan <jn...@gmail.com>

> I don't see any method in SolrServer like what you want.But I think you
> just need write some code with HttpClient ,make a http request use the
> complete query string.
>
> 2013/5/14 Luis Cappa Banda <lu...@gmail.com>
>
> > I know that, but I was wondering if it exists another way just to set the
> > complete query (including q, fq, sort, etc.) embedded in a SolrQuery
> object
> > as the same way that you query using some kind of RequestHandler. That
> way
> > would be more flexible because you don't need to parse the complete query
> > checking q, fg, sort... parameters one by one and setting them with
> > setFields(), setStart(), setRows(), etcetera. Solr is doing that query
> > parse internally when you execute queries with it's REST API and maybe
> > there exist a way to re-use that functionality to just set a String to a
> > SolrQuery and that SolrQuery does internally all the magic.
> >
> > Thanks in advance,
> >
> >
> > 2013/5/14 Jienan Duan <jn...@gmail.com>
> >
> > > hi,
> > > the solrQuery.setQuery() method just set the 'q' param in the query
> > string.
> > > You need call other method to set up all necessary param:
> > > solrQuery.setFields(); --> this set up the 'fl' param
> > > solrQuery.setStart(); --> this set up the 'start' param
> > > solrQuery.setRows(); --> this set up the 'rows' param
> > > solrQuery.setSort();  --> this set up the 'sort'param
> > >
> > > You can look into
> > >
> > >
> >
> http://lucene.apache.org/solr/4_2_1/solr-solrj/org/apache/solr/client/solrj/SolrQuery.htmlto
> > > see more details about SolrQuery.
> > >
> > >
> > > 2013/5/14 Luis Cappa Banda <lu...@gmail.com>
> > >
> > > > Hello, guys!
> > > >
> > > > I would like to do something like this. Let's suppose we have:
> > > >
> > > > *
> > > > *
> > > > *(...) *
> > > > *
> > > > *
> > > > *String query = "q=*:*&start=0&rows=20&sort=date%20desc";*
> > > > *
> > > > *
> > > > *SolrQuery solrQuery = new SolrQuery();*
> > > > *solrQuery.setQuery(query);*
> > > > *
> > > > *
> > > > *server.query(solrQuery);*
> > > > *
> > > > *
> > > > *(...)*
> > > >
> > > >
> > > >
> > > > I tried that and it fails. My question is: is it possible to define a
> > > > SolrQuery with the complete REST encoded query String without parsing
> > > > manually all the query parameters and using SolrQuery methods to set
> > > them?
> > > >
> > > > Regards,
> > > >
> > > > --
> > > > - Luis Cappa
> > > >
> > >
> > >
> > >
> > > --
> > > ------------------------------------------------------
> > > 不走弯路,就是捷径。
> > > http://www.jnan.org/
> > >
> >
> >
> >
> > --
> > - Luis Cappa
> >
>
>
>
> --
> ------------------------------------------------------
> 不走弯路,就是捷径。
> http://www.jnan.org/
>



-- 
- Luis Cappa

Re: Quick SolrJ query how-to question.

Posted by Jienan Duan <jn...@gmail.com>.
I don't see any method in SolrServer like what you want.But I think you
just need write some code with HttpClient ,make a http request use the
complete query string.

2013/5/14 Luis Cappa Banda <lu...@gmail.com>

> I know that, but I was wondering if it exists another way just to set the
> complete query (including q, fq, sort, etc.) embedded in a SolrQuery object
> as the same way that you query using some kind of RequestHandler. That way
> would be more flexible because you don't need to parse the complete query
> checking q, fg, sort... parameters one by one and setting them with
> setFields(), setStart(), setRows(), etcetera. Solr is doing that query
> parse internally when you execute queries with it's REST API and maybe
> there exist a way to re-use that functionality to just set a String to a
> SolrQuery and that SolrQuery does internally all the magic.
>
> Thanks in advance,
>
>
> 2013/5/14 Jienan Duan <jn...@gmail.com>
>
> > hi,
> > the solrQuery.setQuery() method just set the 'q' param in the query
> string.
> > You need call other method to set up all necessary param:
> > solrQuery.setFields(); --> this set up the 'fl' param
> > solrQuery.setStart(); --> this set up the 'start' param
> > solrQuery.setRows(); --> this set up the 'rows' param
> > solrQuery.setSort();  --> this set up the 'sort'param
> >
> > You can look into
> >
> >
> http://lucene.apache.org/solr/4_2_1/solr-solrj/org/apache/solr/client/solrj/SolrQuery.htmlto
> > see more details about SolrQuery.
> >
> >
> > 2013/5/14 Luis Cappa Banda <lu...@gmail.com>
> >
> > > Hello, guys!
> > >
> > > I would like to do something like this. Let's suppose we have:
> > >
> > > *
> > > *
> > > *(...) *
> > > *
> > > *
> > > *String query = "q=*:*&start=0&rows=20&sort=date%20desc";*
> > > *
> > > *
> > > *SolrQuery solrQuery = new SolrQuery();*
> > > *solrQuery.setQuery(query);*
> > > *
> > > *
> > > *server.query(solrQuery);*
> > > *
> > > *
> > > *(...)*
> > >
> > >
> > >
> > > I tried that and it fails. My question is: is it possible to define a
> > > SolrQuery with the complete REST encoded query String without parsing
> > > manually all the query parameters and using SolrQuery methods to set
> > them?
> > >
> > > Regards,
> > >
> > > --
> > > - Luis Cappa
> > >
> >
> >
> >
> > --
> > ------------------------------------------------------
> > 不走弯路,就是捷径。
> > http://www.jnan.org/
> >
>
>
>
> --
> - Luis Cappa
>



-- 
------------------------------------------------------
不走弯路,就是捷径。
http://www.jnan.org/

Re: Quick SolrJ query how-to question.

Posted by Luis Cappa Banda <lu...@gmail.com>.
I know that, but I was wondering if it exists another way just to set the
complete query (including q, fq, sort, etc.) embedded in a SolrQuery object
as the same way that you query using some kind of RequestHandler. That way
would be more flexible because you don't need to parse the complete query
checking q, fg, sort... parameters one by one and setting them with
setFields(), setStart(), setRows(), etcetera. Solr is doing that query
parse internally when you execute queries with it's REST API and maybe
there exist a way to re-use that functionality to just set a String to a
SolrQuery and that SolrQuery does internally all the magic.

Thanks in advance,


2013/5/14 Jienan Duan <jn...@gmail.com>

> hi,
> the solrQuery.setQuery() method just set the 'q' param in the query string.
> You need call other method to set up all necessary param:
> solrQuery.setFields(); --> this set up the 'fl' param
> solrQuery.setStart(); --> this set up the 'start' param
> solrQuery.setRows(); --> this set up the 'rows' param
> solrQuery.setSort();  --> this set up the 'sort'param
>
> You can look into
>
> http://lucene.apache.org/solr/4_2_1/solr-solrj/org/apache/solr/client/solrj/SolrQuery.htmlto
> see more details about SolrQuery.
>
>
> 2013/5/14 Luis Cappa Banda <lu...@gmail.com>
>
> > Hello, guys!
> >
> > I would like to do something like this. Let's suppose we have:
> >
> > *
> > *
> > *(...) *
> > *
> > *
> > *String query = "q=*:*&start=0&rows=20&sort=date%20desc";*
> > *
> > *
> > *SolrQuery solrQuery = new SolrQuery();*
> > *solrQuery.setQuery(query);*
> > *
> > *
> > *server.query(solrQuery);*
> > *
> > *
> > *(...)*
> >
> >
> >
> > I tried that and it fails. My question is: is it possible to define a
> > SolrQuery with the complete REST encoded query String without parsing
> > manually all the query parameters and using SolrQuery methods to set
> them?
> >
> > Regards,
> >
> > --
> > - Luis Cappa
> >
>
>
>
> --
> ------------------------------------------------------
> 不走弯路,就是捷径。
> http://www.jnan.org/
>



-- 
- Luis Cappa

Re: Quick SolrJ query how-to question.

Posted by Jienan Duan <jn...@gmail.com>.
hi,
the solrQuery.setQuery() method just set the 'q' param in the query string.
You need call other method to set up all necessary param:
solrQuery.setFields(); --> this set up the 'fl' param
solrQuery.setStart(); --> this set up the 'start' param
solrQuery.setRows(); --> this set up the 'rows' param
solrQuery.setSort();  --> this set up the 'sort'param

You can look into
http://lucene.apache.org/solr/4_2_1/solr-solrj/org/apache/solr/client/solrj/SolrQuery.htmlto
see more details about SolrQuery.


2013/5/14 Luis Cappa Banda <lu...@gmail.com>

> Hello, guys!
>
> I would like to do something like this. Let's suppose we have:
>
> *
> *
> *(...) *
> *
> *
> *String query = "q=*:*&start=0&rows=20&sort=date%20desc";*
> *
> *
> *SolrQuery solrQuery = new SolrQuery();*
> *solrQuery.setQuery(query);*
> *
> *
> *server.query(solrQuery);*
> *
> *
> *(...)*
>
>
>
> I tried that and it fails. My question is: is it possible to define a
> SolrQuery with the complete REST encoded query String without parsing
> manually all the query parameters and using SolrQuery methods to set them?
>
> Regards,
>
> --
> - Luis Cappa
>



-- 
------------------------------------------------------
不走弯路,就是捷径。
http://www.jnan.org/