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 Cain Jones <ca...@gmail.com> on 2009/09/09 12:15:21 UTC

query too long / has-many relation

Hi all,

I am pretty fresh to solr and I have encountered a problem.

In short:

Is there a way to configure Solr to accept POST queries (instead of GET
only?).
Or: is there some other way to make Solr accept queries longer than 2,000
characters? (Up to 10,000 would be nice)


Longer version:

I have a Solr 1.3 index (served by Tomcat) of People, containing id, name,
address, description etc. This works fine.
Now I want to store and retrieve Events (time location, person), so each
person has 0 or more events.
As I understood it, there is no way to model a has-many relation in Solr (at
least not between two structures with more than 1 properties), so I decided
to store the Events in a separate mysql table.
An example of a query I would like to do is: give me all people that will
have an Event on location x coming month, that have .... in their
description.
I do this in two steps now: first I query the mysql table, then I build a
solr query, with a big OR of all the ids.
The problem is that this can generate long (too long) querystrings.


Thanks in advance,
Cain Jones

Re: query too long / has-many relation

Posted by Alexey Serba <as...@gmail.com>.
> But apart from that everything works fine now (10,000 OR clauses takes 10
> seconds).
Not fast.
I would recommend to denormalize your data, put everything into Solr
index and use Solr faceting
http://wiki.apache.org/solr/SolrFacetingOverview to get relevant
persons ( see my previous message )

Re: query too long / has-many relation

Posted by Cain Jones <ca...@gmail.com>.
I had some trouble with maxBooleanClauses -- I have to set it twice the size
I would expect.
But apart from that everything works fine now (10,000 OR clauses takes 10
seconds).

Thank you Alexey.


On Wed, Sep 9, 2009 at 1:19 PM, Alexey Serba <as...@gmail.com> wrote:

> >> Is there a way to configure Solr to accept POST queries (instead of GET
> >> only?).
> >> Or: is there some other way to make Solr accept queries longer than
> 2,000
> >> characters? (Up to 10,000 would be nice)
> > Solr accepts POST queries by default. I switched to POST for exactly
> > the same reason. I use Solr 1.4 ( trunk version ) though.
> Don't forget to increase maxBooleanClauses in solrconfig.xml
>
> http://wiki.apache.org/solr/SolrConfigXml#head-69ecb985108d73a2f659f2387d916064a2cf63d1
>

Re: query too long / has-many relation

Posted by Alexey Serba <as...@gmail.com>.
>> Is there a way to configure Solr to accept POST queries (instead of GET
>> only?).
>> Or: is there some other way to make Solr accept queries longer than 2,000
>> characters? (Up to 10,000 would be nice)
> Solr accepts POST queries by default. I switched to POST for exactly
> the same reason. I use Solr 1.4 ( trunk version ) though.
Don't forget to increase maxBooleanClauses in solrconfig.xml
http://wiki.apache.org/solr/SolrConfigXml#head-69ecb985108d73a2f659f2387d916064a2cf63d1

Re: query too long / has-many relation

Posted by Alexey Serba <as...@gmail.com>.
> Is there a way to configure Solr to accept POST queries (instead of GET
> only?).
> Or: is there some other way to make Solr accept queries longer than 2,000
> characters? (Up to 10,000 would be nice)
Solr accepts POST queries by default. I switched to POST for exactly
the same reason. I use Solr 1.4 ( trunk version ) though.


> I have a Solr 1.3 index (served by Tomcat) of People, containing id, name,
> address, description etc. This works fine.
> Now I want to store and retrieve Events (time location, person), so each
> person has 0 or more events.
> As I understood it, there is no way to model a has-many relation in Solr (at
> least not between two structures with more than 1 properties), so I decided
> to store the Events in a separate mysql table.
> An example of a query I would like to do is: give me all people that will
> have an Event on location x coming month, that have .... in their
> description.
> I do this in two steps now: first I query the mysql table, then I build a
> solr query, with a big OR of all the ids.
> The problem is that this can generate long (too long) querystrings.
Another option would be to put all your event objects (time, location,
person_id, description) into Solr index ( normalization )
Then you can generate Solr query "give me all events on location x
coming month that have smth in their description" and asks Solr to
return facets values for field person_id. Solr will return all
distinct values of field "person_id" that matches the query with count
values. Then you can take list of related person_ids and load all
persons from MySQL database using SQL "in IN ()" clause.