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 davidbougearel <da...@smile-benelux.com> on 2012/07/04 15:09:54 UTC

Solr facet multiple constraint

Hi,

I'm trying to make a facet search on a multiple value field and add a filter
query on it and it doesn't work.
Could you please help me find my mistake ?

Here is my solr query :

facet=true,sort=publishingdate desc,facet.mincount=1,q=service:1 AND
publicationstatus:LIVE,facet.field={!ex=dt}user,wt=javabin,fq={!tag=dt}user:10,version=2

Thanks in advance for answers, David. 

--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by Erick Erickson <er...@gmail.com>.
NP, glad it's working for you!

On Fri, Jul 20, 2012 at 8:26 AM, davidbougearel
<da...@smile-benelux.com> wrote:
> I have tried and it works !
>
> Thanks again a lot for this dude !
>
> Regards,
> David.
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3996189.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by davidbougearel <da...@smile-benelux.com>.
I have tried and it works !

Thanks again a lot for this dude !

Regards,
David.



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3996189.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by davidbougearel <da...@smile-benelux.com>.
Ok it's nice a facet query, i will try this feature and will reply you but i
think that's the point, thanks a lot for time spent :)



--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3996186.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by Erick Erickson <er...@gmail.com>.
OK, maybe I'm finally getting it. When you do a facet.field=blahblah, you're
telling Solr to take all the documents that match the query, look in field
blahblah, and tally the documents that match _any_ value in the field. There's
no restriction at all on the _values_ that that tally is made for.

If I'm _finally_ understanding you, you only want tallys for the values in
your fq clause, have you considered facet queries?

facet.query=user:10&facet.query=user:3.... will give you the counts for all the
docs that match your query (q and fq clauses), but only return you the facets
for the indicated users. You can have as many facet.query clauses as you want.

Best
Erick

On Mon, Jul 16, 2012 at 4:00 AM, davidbougearel
<da...@smile-benelux.com> wrote:
> Ok i'm added the debug, there is the query from the response after executing
> query :
>
> facet=true,sort=publishingdate
> desc,debugQuery=true,facet.mincount=1,q=service:1 AND
> publicationstatus:LIVE,facet.field=pillar,wt=javabin,fq=(((pillar:10))),version=2}},response={numFound=2,start=0,docs=[SolrDocument[{uniquenumber=UniqueNumber1,
> name=Doc 1, publicationstatus=LIVE, service=1, servicename=service_1,
> pillar=[10], region=EU, regionname=Europe, documenttype=TRACKER,
> publishingdate=Sun Jul 15 09:03:32 CEST 2012, publishingyear=2012,
> teasersummary=Seo_Description, content=answer, creator=chandan, version=1,
> documentinstanceid=1}], SolrDocument[{uniquenumber=UniqueNumber2, name=Doc
> 2, publicationstatus=LIVE, service=1, servicename=service_1, pillar=[10],
> region=EU, regionname=Europe, documenttype=TRACKER, publishingdate=Sat Jul
> 14 09:03:32 CEST 2012, publishingyear=2012, teasersummary=Seo_Description,
> content=answer, creator=chandan, version=1,
> documentinstanceid=1}]]},facet_counts={facet_queries={},facet_fields={pillar={10=2}},facet_dates={},facet_ranges={}},debug={rawquerystring=service:1
> AND publicationstatus:LIVE,querystring=service:1 AND
> publicationstatus:LIVE,parsedquery=+service:1
> +publicationstatus:LIVE,parsedquery_toString=+service:1
> +publicationstatus:LIVE,explain={UniqueNumber1=
> 1.2917422 = (MATCH) sum of:
>   0.7741482 = (MATCH) weight(service:1 in 0), product of:
>     0.7741482 = queryWeight(service:1), product of:
>       1.0 = idf(docFreq=4, maxDocs=5)
>       0.7741482 = queryNorm
>     1.0 = (MATCH) fieldWeight(service:1 in 0), product of:
>       1.0 = tf(termFreq(service:1)=1)
>       1.0 = idf(docFreq=4, maxDocs=5)
>       1.0 = fieldNorm(field=service, doc=0)
>   0.517594 = (MATCH) weight(publicationstatus:LIVE in 0), product of:
>     0.6330043 = queryWeight(publicationstatus:LIVE), product of:
>       0.81767845 = idf(docFreq=5, maxDocs=5)
>       0.7741482 = queryNorm
>     0.81767845 = (MATCH) fieldWeight(publicationstatus:LIVE in 0), product
> of:
>       1.0 = tf(termFreq(publicationstatus:LIVE)=1)
>       0.81767845 = idf(docFreq=5, maxDocs=5)
>       1.0 = fieldNorm(field=publicationstatus, doc=0)
> ,UniqueNumber2=
> 1.2917422 = (MATCH) sum of:
>   0.7741482 = (MATCH) weight(service:1 in 0), product of:
>     0.7741482 = queryWeight(service:1), product of:
>       1.0 = idf(docFreq=4, maxDocs=5)
>       0.7741482 = queryNorm
>     1.0 = (MATCH) fieldWeight(service:1 in 0), product of:
>       1.0 = tf(termFreq(service:1)=1)
>       1.0 = idf(docFreq=4, maxDocs=5)
>       1.0 = fieldNorm(field=service, doc=0)
>   0.517594 = (MATCH) weight(publicationstatus:LIVE in 0), product of:
>     0.6330043 = queryWeight(publicationstatus:LIVE), product of:
>       0.81767845 = idf(docFreq=5, maxDocs=5)
>       0.7741482 = queryNorm
>     0.81767845 = (MATCH) fieldWeight(publicationstatus:LIVE in 0), product
> of:
>       1.0 = tf(termFreq(publicationstatus:LIVE)=1)
>       0.81767845 = idf(docFreq=5, maxDocs=5)
>       1.0 = fieldNorm(field=publicationstatus, doc=0)
> },QParser=LuceneQParser,filter_queries=[(((pillar:10)))
>
> As you can see in this request i'm talking about pillar not about user.
>
> Thanks for all, David.
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3995215.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by davidbougearel <da...@smile-benelux.com>.
Ok i'm added the debug, there is the query from the response after executing
query :

facet=true,sort=publishingdate
desc,debugQuery=true,facet.mincount=1,q=service:1 AND
publicationstatus:LIVE,facet.field=pillar,wt=javabin,fq=(((pillar:10))),version=2}},response={numFound=2,start=0,docs=[SolrDocument[{uniquenumber=UniqueNumber1,
name=Doc 1, publicationstatus=LIVE, service=1, servicename=service_1,
pillar=[10], region=EU, regionname=Europe, documenttype=TRACKER,
publishingdate=Sun Jul 15 09:03:32 CEST 2012, publishingyear=2012,
teasersummary=Seo_Description, content=answer, creator=chandan, version=1,
documentinstanceid=1}], SolrDocument[{uniquenumber=UniqueNumber2, name=Doc
2, publicationstatus=LIVE, service=1, servicename=service_1, pillar=[10],
region=EU, regionname=Europe, documenttype=TRACKER, publishingdate=Sat Jul
14 09:03:32 CEST 2012, publishingyear=2012, teasersummary=Seo_Description,
content=answer, creator=chandan, version=1,
documentinstanceid=1}]]},facet_counts={facet_queries={},facet_fields={pillar={10=2}},facet_dates={},facet_ranges={}},debug={rawquerystring=service:1
AND publicationstatus:LIVE,querystring=service:1 AND
publicationstatus:LIVE,parsedquery=+service:1
+publicationstatus:LIVE,parsedquery_toString=+service:1
+publicationstatus:LIVE,explain={UniqueNumber1=
1.2917422 = (MATCH) sum of:
  0.7741482 = (MATCH) weight(service:1 in 0), product of:
    0.7741482 = queryWeight(service:1), product of:
      1.0 = idf(docFreq=4, maxDocs=5)
      0.7741482 = queryNorm
    1.0 = (MATCH) fieldWeight(service:1 in 0), product of:
      1.0 = tf(termFreq(service:1)=1)
      1.0 = idf(docFreq=4, maxDocs=5)
      1.0 = fieldNorm(field=service, doc=0)
  0.517594 = (MATCH) weight(publicationstatus:LIVE in 0), product of:
    0.6330043 = queryWeight(publicationstatus:LIVE), product of:
      0.81767845 = idf(docFreq=5, maxDocs=5)
      0.7741482 = queryNorm
    0.81767845 = (MATCH) fieldWeight(publicationstatus:LIVE in 0), product
of:
      1.0 = tf(termFreq(publicationstatus:LIVE)=1)
      0.81767845 = idf(docFreq=5, maxDocs=5)
      1.0 = fieldNorm(field=publicationstatus, doc=0)
,UniqueNumber2=
1.2917422 = (MATCH) sum of:
  0.7741482 = (MATCH) weight(service:1 in 0), product of:
    0.7741482 = queryWeight(service:1), product of:
      1.0 = idf(docFreq=4, maxDocs=5)
      0.7741482 = queryNorm
    1.0 = (MATCH) fieldWeight(service:1 in 0), product of:
      1.0 = tf(termFreq(service:1)=1)
      1.0 = idf(docFreq=4, maxDocs=5)
      1.0 = fieldNorm(field=service, doc=0)
  0.517594 = (MATCH) weight(publicationstatus:LIVE in 0), product of:
    0.6330043 = queryWeight(publicationstatus:LIVE), product of:
      0.81767845 = idf(docFreq=5, maxDocs=5)
      0.7741482 = queryNorm
    0.81767845 = (MATCH) fieldWeight(publicationstatus:LIVE in 0), product
of:
      1.0 = tf(termFreq(publicationstatus:LIVE)=1)
      0.81767845 = idf(docFreq=5, maxDocs=5)
      1.0 = fieldNorm(field=publicationstatus, doc=0)
},QParser=LuceneQParser,filter_queries=[(((pillar:10)))

As you can see in this request i'm talking about pillar not about user.

Thanks for all, David.

--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3995215.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by Erick Erickson <er...@gmail.com>.
What do you get when you attach &debugQuery=on? That should show you the parsed
query. You might paste that.

Erick

On Fri, Jul 13, 2012 at 1:14 AM, davidbougearel
<da...@smile-benelux.com> wrote:
> Ok well i know about the complexity that i can put into fq with AND and OR
> conditions but at the moment when i put fq=user:10,facet.field=user, the
> query returns me all the facets not taking into account the fq=user:10
> that's the problem.
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3994783.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by davidbougearel <da...@smile-benelux.com>.
Ok well i know about the complexity that i can put into fq with AND and OR
conditions but at the moment when i put fq=user:10,facet.field=user, the
query returns me all the facets not taking into account the fq=user:10
that's the problem.

--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3994783.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by Erick Erickson <er...@gmail.com>.
Sure, you can have as complex an FQ clause as you need.

Best
Erick

On Thu, Jul 12, 2012 at 1:48 AM, davidbougearel
<da...@smile-benelux.com> wrote:
> Ok this is the id but in fact (sorry about this) my wish is the reverse, i
> want to get just the facet for which a have the right so i want to put
> fq=user:10 in order to get only facet with user:10.
>
> In my fq i can have something like user:10 AND user:3 because it's auto
> generated by rights of my application.
>
> Have you any idea to solve this ?
>
> Really thanks to help me, we are waiting a solution for this because instead
> of this we should make a lot of queries to get the right result.
>
> Best regards, David.
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3994574.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by davidbougearel <da...@smile-benelux.com>.
Ok this is the id but in fact (sorry about this) my wish is the reverse, i
want to get just the facet for which a have the right so i want to put
fq=user:10 in order to get only facet with user:10.

In my fq i can have something like user:10 AND user:3 because it's auto
generated by rights of my application.

Have you any idea to solve this ?

Really thanks to help me, we are waiting a solution for this because instead
of this we should make a lot of queries to get the right result.

Best regards, David.

--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3994574.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by Erick Erickson <er...@gmail.com>.
OK, would it work just add an fq clause fq=-user:10? Or, depending on your Solr,
fq=*:* -user:10?

Best
Erick

On Tue, Jul 10, 2012 at 5:45 AM, davidbougearel
<da...@smile-benelux.com> wrote:
> Ok sorry to not be clear and thanks again for your answers.
>
> q=service%3A1+AND+publicationstatus%3ALIVE&sort=publishingdate+desc&fq=%7B%21ex%3Ddt%7D%28%28%28user%3A10%29%29%29&facet.field=%7B%21tag%3Ddt%7Duser&facet=true&facet.mincount=1
>
> Here with this query i want to get all the documents (the elements stored
> are documents) tagged by user facet with the service=1 but with the
> constraint that i dont want the user facet user:10.
>
> So if i had all the facets users like this : user:1, user:2, user:10, i
> expect to get documents tagged on user:1 and user:2 only not the facet one
> with user:10 even if those documents are tagged to service:1.
>
> Is it more clear ?
>
> Regards, David.
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3994109.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by davidbougearel <da...@smile-benelux.com>.
Ok sorry to not be clear and thanks again for your answers.

q=service%3A1+AND+publicationstatus%3ALIVE&sort=publishingdate+desc&fq=%7B%21ex%3Ddt%7D%28%28%28user%3A10%29%29%29&facet.field=%7B%21tag%3Ddt%7Duser&facet=true&facet.mincount=1

Here with this query i want to get all the documents (the elements stored
are documents) tagged by user facet with the service=1 but with the
constraint that i dont want the user facet user:10.

So if i had all the facets users like this : user:1, user:2, user:10, i
expect to get documents tagged on user:1 and user:2 only not the facet one
with user:10 even if those documents are tagged to service:1.

Is it more clear ?

Regards, David.

--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3994109.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by Erick Erickson <er...@gmail.com>.
You still haven't given a clear (at least to me) statement of
what you see and what about it isn't what you expect. Please
give some concrete examples.

Best
Erick

On Mon, Jul 9, 2012 at 3:45 AM, davidbougearel
<da...@smile-benelux.com> wrote:
> Thanks for answer,
>
> Actually when i put 'it's not working' it means that it's not the result
> expected : the result return me data tagged by all the facets not only the
> facet that i ask for with the constraint.
>
> Hope you will help me.
>
> Best regards,
>
> David.
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3993822.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by davidbougearel <da...@smile-benelux.com>.
Thanks for answer,

Actually when i put 'it's not working' it means that it's not the result
expected : the result return me data tagged by all the facets not only the
facet that i ask for with the constraint.

Hope you will help me.

Best regards,

David.

--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3993822.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by Erick Erickson <er...@gmail.com>.
What does "doesn't work" mean? returning no results? Not returning facets?
returning incorrect facet counts?

You might review:
http://wiki.apache.org/solr/UsingMailingLists

Best
Erick

On Fri, Jul 6, 2012 at 1:37 AM, davidbougearel
<da...@smile-benelux.com> wrote:
> Well thanks for your answer, in fact i've written what the QueryResponse
> return as the solr query here is my real solr query before use the
> executeQuery :
>
> q=service%3A1+AND+publicationstatus%3ALIVE&sort=publishingdate+desc&fq=%7B%21ex%3Ddt%7D%28%28%28user%3A10%29%29%29&facet.field=%7B%21tag%3Ddt%7Duser&facet=true&facet.mincount=1
>
> which is the same as my first post without the 'wt=javabin' and & instead of
> commas.
>
> Could you please see if there is something wrong for you ?
>
> Best regards,
>
> David.
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3993408.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by davidbougearel <da...@smile-benelux.com>.
Well thanks for your answer, in fact i've written what the QueryResponse
return as the solr query here is my real solr query before use the
executeQuery :

q=service%3A1+AND+publicationstatus%3ALIVE&sort=publishingdate+desc&fq=%7B%21ex%3Ddt%7D%28%28%28user%3A10%29%29%29&facet.field=%7B%21tag%3Ddt%7Duser&facet=true&facet.mincount=1

which is the same as my first post without the 'wt=javabin' and & instead of
commas.

Could you please see if there is something wrong for you ?

Best regards, 

David.

--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3993408.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by Erick Erickson <er...@gmail.com>.
Well, to start with this query is totally messed up.

facet=true,sort=publishingdate desc,facet.mincount=1,q=service:1 AND
publicationstatus:LIVE,facet.field={!ex=dt}user,wt=javabin,fq={!tag=dt}user:10,version=2

You've put in commas where you should have ampersands to separate
parameters=value pairs.

e.g.
facet=true&sort=publishingdate desc&facet.mincount=1&q=service:1 AND
publicationstatus:LIVE&facet.field={!ex=dt}user,wt=javabin,fq={!tag=dt}user:10,version=2


Best
Erick

On Thu, Jul 5, 2012 at 1:17 AM, davidbougearel
<da...@smile-benelux.com> wrote:
> Please someone can help me,
>
> we are a team waiting for a fix.
> We try several ways to implement it without success.
>
> Thanks for reading anyway, David.
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3993119.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Solr facet multiple constraint

Posted by davidbougearel <da...@smile-benelux.com>.
Please someone can help me, 

we are a team waiting for a fix.
We try several ways to implement it without success.

Thanks for reading anyway, David.

--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-facet-multiple-constraint-tp3992974p3993119.html
Sent from the Solr - User mailing list archive at Nabble.com.