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 "Marta (motagirl2)" <mo...@gmail.com> on 2016/08/26 13:09:06 UTC

Get results from Solr facets

Hi everybody,
I am pretty new to Solr, so I don't know if what I'd like to achieve is
actually feasible or not. Currently, I am querying my Solr to retrieve the
amount of results that match the conditions in several facet queries. For
example:

localhost:8082/solr/dict/select?q=*:*&rows=0&wt=json&indent=true&facet=true&facet.query=dict1:"#tiger#"&facet.query=dict1:"#lion#"

With this kind of query, I am getting the count of Solr docs containing
"tiger" and the count of those cointaining "lion", in field "dict1":

 {
  "responseHeader": {
    "status": 0,
    "QTime": 239,
    "params": {
      "facet.query": [
        "dict1:\"#tiger#\"",
        "dict1:\"#lion#\""
      ],
      "q": "*:*",
      "indent": "true",
      "rows": "0",
      "wt": "json",
      "facet": "true"
    }
  },
  "response": {
    "numFound": 37278987,
    "start": 0,
    "docs": [ ]
  },
  "facet_counts": {
    "facet_queries": {
      "dict1:\"#tiger#\"": 6,
      "dict1:\"#lion#\"": 10
    },
    [...]
  }
}

The thing is that now I need to get also some results for each facet, aside
as the count (for example, three results for "tiger" and three more for
"lion")

I have read some similar questions (Solr Facetting - Showing First 10
results and Other
<http://stackoverflow.com/questions/1808515/solr-facetting-showing-first-10-results-and-other>
 or SOLR - Querying Facets, return N results per Facet
<http://stackoverflow.com/questions/24019531/solr-querying-facets-return-n-results-per-facet>
)
, but none of their answers seems to work for me, maybe because I am doing
the facets on all docs (q=*:*).

Any help will be welcome :)


(I posted this issue also in Stackoverflow, you can see it here
http://stackoverflow.com/questions/39164957/get-results-from-solr-facets )
-- 
marta - motagirl
http://motagirl.net

Re: Get results from Solr facets

Posted by Alessandro Benedetti <ab...@apache.org>.
What about simply using grouping ?

solr/hotels/search?q=*%3A*&wt=json&indent=true&group=true&group.query=query1&group.query=query2&group.limit=3
[1]

is this ok for you ?

[1] https://cwiki.apache.org/confluence/display/solr/Result+Grouping

Cheers

On Fri, Aug 26, 2016 at 2:09 PM, Marta (motagirl2) <mo...@gmail.com>
wrote:

> Hi everybody,
> I am pretty new to Solr, so I don't know if what I'd like to achieve is
> actually feasible or not. Currently, I am querying my Solr to retrieve the
> amount of results that match the conditions in several facet queries. For
> example:
>
> localhost:8082/solr/dict/select?q=*:*&rows=0&wt=json&
> indent=true&facet=true&facet.query=dict1:"#tiger#"&facet.
> query=dict1:"#lion#"
>
> With this kind of query, I am getting the count of Solr docs containing
> "tiger" and the count of those cointaining "lion", in field "dict1":
>
>  {
>   "responseHeader": {
>     "status": 0,
>     "QTime": 239,
>     "params": {
>       "facet.query": [
>         "dict1:\"#tiger#\"",
>         "dict1:\"#lion#\""
>       ],
>       "q": "*:*",
>       "indent": "true",
>       "rows": "0",
>       "wt": "json",
>       "facet": "true"
>     }
>   },
>   "response": {
>     "numFound": 37278987,
>     "start": 0,
>     "docs": [ ]
>   },
>   "facet_counts": {
>     "facet_queries": {
>       "dict1:\"#tiger#\"": 6,
>       "dict1:\"#lion#\"": 10
>     },
>     [...]
>   }
> }
>
> The thing is that now I need to get also some results for each facet, aside
> as the count (for example, three results for "tiger" and three more for
> "lion")
>
> I have read some similar questions (Solr Facetting - Showing First 10
> results and Other
> <http://stackoverflow.com/questions/1808515/solr-
> facetting-showing-first-10-results-and-other>
>  or SOLR - Querying Facets, return N results per Facet
> <http://stackoverflow.com/questions/24019531/solr-
> querying-facets-return-n-results-per-facet>
> )
> , but none of their answers seems to work for me, maybe because I am doing
> the facets on all docs (q=*:*).
>
> Any help will be welcome :)
>
>
> (I posted this issue also in Stackoverflow, you can see it here
> http://stackoverflow.com/questions/39164957/get-results-from-solr-facets )
> --
> marta - motagirl
> http://motagirl.net
>



-- 
--------------------------

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"Tyger, tyger burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?"

William Blake - Songs of Experience -1794 England

Re: Get results from Solr facets

Posted by Mikhail Khludnev <mk...@apache.org>.
Hello,

Have you checked json.facets? They allow to combine a lot of such
instructions like this.

On Fri, Aug 26, 2016 at 4:09 PM, Marta (motagirl2) <mo...@gmail.com>
wrote:

> Hi everybody,
> I am pretty new to Solr, so I don't know if what I'd like to achieve is
> actually feasible or not. Currently, I am querying my Solr to retrieve the
> amount of results that match the conditions in several facet queries. For
> example:
>
> localhost:8082/solr/dict/select?q=*:*&rows=0&wt=json&
> indent=true&facet=true&facet.query=dict1:"#tiger#"&facet.
> query=dict1:"#lion#"
>
> With this kind of query, I am getting the count of Solr docs containing
> "tiger" and the count of those cointaining "lion", in field "dict1":
>
>  {
>   "responseHeader": {
>     "status": 0,
>     "QTime": 239,
>     "params": {
>       "facet.query": [
>         "dict1:\"#tiger#\"",
>         "dict1:\"#lion#\""
>       ],
>       "q": "*:*",
>       "indent": "true",
>       "rows": "0",
>       "wt": "json",
>       "facet": "true"
>     }
>   },
>   "response": {
>     "numFound": 37278987,
>     "start": 0,
>     "docs": [ ]
>   },
>   "facet_counts": {
>     "facet_queries": {
>       "dict1:\"#tiger#\"": 6,
>       "dict1:\"#lion#\"": 10
>     },
>     [...]
>   }
> }
>
> The thing is that now I need to get also some results for each facet, aside
> as the count (for example, three results for "tiger" and three more for
> "lion")
>
> I have read some similar questions (Solr Facetting - Showing First 10
> results and Other
> <http://stackoverflow.com/questions/1808515/solr-
> facetting-showing-first-10-results-and-other>
>  or SOLR - Querying Facets, return N results per Facet
> <http://stackoverflow.com/questions/24019531/solr-
> querying-facets-return-n-results-per-facet>
> )
> , but none of their answers seems to work for me, maybe because I am doing
> the facets on all docs (q=*:*).
>
> Any help will be welcome :)
>
>
> (I posted this issue also in Stackoverflow, you can see it here
> http://stackoverflow.com/questions/39164957/get-results-from-solr-facets )
> --
> marta - motagirl
> http://motagirl.net
>



-- 
Sincerely yours
Mikhail Khludnev