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 abhayd <aj...@hotmail.com> on 2011/10/03 21:42:32 UTC

sorting using function query results are notin order

hi 
I am trying to sort results from solr using sum(count,score) function.
Basically its not adding things correctly.  
For example here is partial sample response
        "Count":54,
        "UserQuery":"how to",
        "score":1.2550932,
        "query({!dismax qf=UserQuery v='how'})":1.2550932,
        "sum(Count,query({!dismax qf=UserQuery v='how'}))":1.2550932},

how come addition of 54+1.2550932 is equla to 1.2550932 ?as if

What i m doing wrong?
here is my complete query
------------------------------------
http://localhost:10101/solr/autosuggest/select?q=how&start=0&indent=on&wt=json&rows=5&sort=sum%28Count,query%28{!dismax%20qf=UserQuery%20v=%27how%27}%29%29%20desc&fl=UserQuery,score,Count,query%28{!dismax%20qf=UserQuery%20v=%27how%27}%29,sum%28Count,query%28{!dismax%20qf=UserQuery%20v=%27how%27}%29%29&debug=true

{
  "responseHeader":{
    "status":0,
    "QTime":0,
    "params":{
      "sort":"sum(Count,query({!dismax qf=UserQuery v='how'})) desc",
      "wt":"json",
      "rows":"5",
      "indent":"on",
      "fl":"UserQuery,score,Count,query({!dismax qf=UserQuery
v='how'}),sum(Count,query({!dismax qf=UserQuery v='how'}))",
      "debug":"true",
      "start":"0",
      "q":"how"}},
  "response":{"numFound":2628,"start":0,"maxScore":1.2550932,"docs":[
      {
        "Count":54,
        "UserQuery":"how to",
        "score":1.2550932,
        "query({!dismax qf=UserQuery v='how'})":1.2550932,
        "sum(Count,query({!dismax qf=UserQuery v='how'}))":1.2550932},
      {
        "Count":51,
        "UserQuery":"how to text",
        "score":0.8964951,
        "query({!dismax qf=UserQuery v='how'})":0.8964951,
        "sum(Count,query({!dismax qf=UserQuery v='how'}))":0.8964951},
      {
        "Count":117,
        "UserQuery":"how to block calls",
        "score":0.7171961,
        "query({!dismax qf=UserQuery v='how'})":0.7171961,
        "sum(Count,query({!dismax qf=UserQuery v='how'}))":0.7171961},
      {
        "Count":109,
        "UserQuery":"how to call forward",
        "score":0.7171961,
        "query({!dismax qf=UserQuery v='how'})":0.7171961,
        "sum(Count,query({!dismax qf=UserQuery v='how'}))":0.7171961},
      {
        "Count":79,
        "UserQuery":"how do I pay my bill?",
        "score":0.7171961,
        "query({!dismax qf=UserQuery v='how'})":0.7171961,
        "sum(Count,query({!dismax qf=UserQuery v='how'}))":0.7171961}]
  },


--
View this message in context: http://lucene.472066.n3.nabble.com/sorting-using-function-query-results-are-notin-order-tp3390926p3390926.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: sorting using function query results are notin order

Posted by abhayd <aj...@hotmail.com>.
hi hoss,
I see this in change.txt
$Id: CHANGES.txt 1148494 2011-07-19 19:25:01Z hossman $

repository root: http://svn.apache.org/repos/asf/lucene/dev/trunk
Revision:1148519

If u let me know what/where to look for i can send details.

Here is field defination

   <field name="Count" type="sint" indexed="true" stored="true"
multiValued="false"/>



--
View this message in context: http://lucene.472066.n3.nabble.com/sorting-using-function-query-results-are-notin-order-tp3390926p3395385.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: sorting using function query results are notin order

Posted by Chris Hostetter <ho...@fucit.org>.
:       solr-spec-version
:           4.0.0.2011.07.19.16.15.08
:       solr-impl-version
:           4.0-SNAPSHOT ${svnversion} - ad895d - 2011-07-19 16:15:08

Uh, ok ... that doesn't really answer my question at all.

According to that info, your version of solr was *built* on 2011-07-19, 
using some snapshot of trunk, but the svn version info is missing, so 
there is know way of knowing how old that snapshot is.  

you also didn't answer my question about the field type you are using for 
Count.

details matter.

SOLR-2348 was commited to trunk on 2011-02-17 (r1071459).  When i tried to 
reproduce your example using the current trunk, and an un-indexed 
TrieIntField (i edited "popularity" in the example schema.xml to make it 
indexed="false") i got the expected error message instead of silently 
computing he wrong value when i tried to use popularity in a function...

http://localhost:8983/solr/select?q=ipod&fl=id,product%28popularity,price%29

So unless your 2011-07-19 build was from a version of svn that was already 
4 months old, there may still be something wrong that we should try to get 
to the bottom of.


-Hoss

Re: sorting using function query results are notin order

Posted by abhayd <aj...@hotmail.com>.
hi
      solr-spec-version
          4.0.0.2011.07.19.16.15.08
      solr-impl-version
          4.0-SNAPSHOT ${svnversion} - ad895d - 2011-07-19 16:15:08
      lucene-spec-version
          4.0-SNAPSHOT
      lucene-impl-version
          4.0-SNAPSHOT ${svnversion} - ad895d - 2011-07-19 16:15:13



--
View this message in context: http://lucene.472066.n3.nabble.com/sorting-using-function-query-results-are-notin-order-tp3390926p3395106.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: sorting using function query results are notin order

Posted by Chris Hostetter <ho...@fucit.org>.
: Subject: Re: sorting using function query results are notin order
: 
: that was it..COunt was not indexed...works fine now

Hmmm... which version of solr are you using?  
what exactly is the FieldType of your "Count" field?

Since Solr 3.1, attempting to use a function on a non-indexed field 
*should* fail with a clear error...

https://issues.apache.org/jira/browse/SOLR-2348




-Hoss

Re: sorting using function query results are notin order

Posted by abhayd <aj...@hotmail.com>.
that was it..COunt was not indexed...works fine now

--
View this message in context: http://lucene.472066.n3.nabble.com/sorting-using-function-query-results-are-notin-order-tp3390926p3394876.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: sorting using function query results are notin order

Posted by Yonik Seeley <yo...@lucidimagination.com>.
Hmmm, try adding fl={!func}Count
to make sure Count is an indexed field and function queries are
getting the right values.

-Yonik
http://www.lucene-eurocon.com - The Lucene/Solr User Conference



On Mon, Oct 3, 2011 at 3:42 PM, abhayd <aj...@hotmail.com> wrote:
> hi
> I am trying to sort results from solr using sum(count,score) function.
> Basically its not adding things correctly.
> For example here is partial sample response
>        "Count":54,
>        "UserQuery":"how to",
>        "score":1.2550932,
>        "query({!dismax qf=UserQuery v='how'})":1.2550932,
>        "sum(Count,query({!dismax qf=UserQuery v='how'}))":1.2550932},
>
> how come addition of 54+1.2550932 is equla to 1.2550932 ?as if
>
> What i m doing wrong?
> here is my complete query
> ------------------------------------
> http://localhost:10101/solr/autosuggest/select?q=how&start=0&indent=on&wt=json&rows=5&sort=sum%28Count,query%28{!dismax%20qf=UserQuery%20v=%27how%27}%29%29%20desc&fl=UserQuery,score,Count,query%28{!dismax%20qf=UserQuery%20v=%27how%27}%29,sum%28Count,query%28{!dismax%20qf=UserQuery%20v=%27how%27}%29%29&debug=true
>
> {
>  "responseHeader":{
>    "status":0,
>    "QTime":0,
>    "params":{
>      "sort":"sum(Count,query({!dismax qf=UserQuery v='how'})) desc",
>      "wt":"json",
>      "rows":"5",
>      "indent":"on",
>      "fl":"UserQuery,score,Count,query({!dismax qf=UserQuery
> v='how'}),sum(Count,query({!dismax qf=UserQuery v='how'}))",
>      "debug":"true",
>      "start":"0",
>      "q":"how"}},
>  "response":{"numFound":2628,"start":0,"maxScore":1.2550932,"docs":[
>      {
>        "Count":54,
>        "UserQuery":"how to",
>        "score":1.2550932,
>        "query({!dismax qf=UserQuery v='how'})":1.2550932,
>        "sum(Count,query({!dismax qf=UserQuery v='how'}))":1.2550932},
>      {
>        "Count":51,
>        "UserQuery":"how to text",
>        "score":0.8964951,
>        "query({!dismax qf=UserQuery v='how'})":0.8964951,
>        "sum(Count,query({!dismax qf=UserQuery v='how'}))":0.8964951},
>      {
>        "Count":117,
>        "UserQuery":"how to block calls",
>        "score":0.7171961,
>        "query({!dismax qf=UserQuery v='how'})":0.7171961,
>        "sum(Count,query({!dismax qf=UserQuery v='how'}))":0.7171961},
>      {
>        "Count":109,
>        "UserQuery":"how to call forward",
>        "score":0.7171961,
>        "query({!dismax qf=UserQuery v='how'})":0.7171961,
>        "sum(Count,query({!dismax qf=UserQuery v='how'}))":0.7171961},
>      {
>        "Count":79,
>        "UserQuery":"how do I pay my bill?",
>        "score":0.7171961,
>        "query({!dismax qf=UserQuery v='how'})":0.7171961,
>        "sum(Count,query({!dismax qf=UserQuery v='how'}))":0.7171961}]
>  },
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/sorting-using-function-query-results-are-notin-order-tp3390926p3390926.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: sorting using function query results are notin order

Posted by abhayd <aj...@hotmail.com>.
any help?

--
View this message in context: http://lucene.472066.n3.nabble.com/sorting-using-function-query-results-are-notin-order-tp3390926p3393781.html
Sent from the Solr - User mailing list archive at Nabble.com.