Here is our SOLR query: http://qa-solr:8080/solr/select?q=type:PortalCase&json.facet={categories:{terms:{field:campaign_id_ls,sort:%27count+asc%27}}}&rows=0
I replaced "cats" with "categories". It is still not working. On Sun, May 10, 2015 at 12:10 AM, Frank li <fudon...@gmail.com> wrote: > Thank you, Yonik! > > Looks cool to me. Only problem is it is not working for me. > I see you have "cats" and "cat" in your URL. "cat" must be a field name. > What is "cats"? > > We are doing a POC with facet count ascending. You help is really > important to us. > > > > On Sat, May 9, 2015 at 8:05 AM, Yonik Seeley <ysee...@gmail.com> wrote: > >> curl -g " >> http://localhost:8983/solr/techproducts/query?q=*:*&json.facet={cats:{terms:{field:cat,sort:'count+asc'}}} >> <http://localhost:8983/solr/techproducts/query?q=*:*&json.facet=%7Bcats:%7Bterms:%7Bfield:cat,sort:'count+asc'%7D%7D%7D> >> " >> >> Using curl with everything in the URL is definitely trickier. >> Everything needs to be URL escaped. If it's not, curl will often >> silently do nothing. >> For example, when I had sort:'count asc' , the command above would do >> nothing. When I remembered to URL encode the space as a "+", it >> started working. >> >> It's definitely easier to use "-d" with curl... >> >> curl "http://localhost:8983/solr/techproducts/query" -d >> 'q=*:*&json.facet={cats:{terms:{field:cat,sort:"count asc"}}}' >> >> That also allows you to format it nicer for reading as well: >> >> curl "http://localhost:8983/solr/techproducts/query" -d >> 'q=*:*&json.facet= >> {cats:{terms:{ >> field:cat, >> sort:"count asc" >> }}}' >> >> -Yonik >> >> >> On Thu, May 7, 2015 at 5:32 PM, Frank li <fudon...@gmail.com> wrote: >> > This one does not have problem, but how do I include "sort" in this >> facet >> > query. Basically, I want to write a solr query which can sort the facet >> > count ascending. Something like "http://localhost:8983/solr >> > /demo/query?q=apple&json.facet={field=price sort='count asc'} >> > < >> http://localhost:8983/solr/demo/query?q=apple&json.facet=%7Bx:%27avg%28price%29%27%7D >> > >> > >> > I really appreciate your help. >> > >> > Frank >> > >> > < >> http://localhost:8983/solr/demo/query?q=apple&json.facet=%7Bx:%27avg%28price%29%27%7D >> > >> > >> > On Thu, May 7, 2015 at 2:24 PM, Yonik Seeley <ysee...@gmail.com> wrote: >> > >> >> On Thu, May 7, 2015 at 4:47 PM, Frank li <fudon...@gmail.com> wrote: >> >> > Hi Yonik, >> >> > >> >> > I am reading your blog. It is helpful. One question for you, for >> >> following >> >> > example, >> >> > >> >> > curl http://localhost:8983/solr/query -d 'q=*:*&rows=0& >> >> > json.facet={ >> >> > categories:{ >> >> > type : terms, >> >> > field : cat, >> >> > sort : { x : desc}, >> >> > facet:{ >> >> > x : "avg(price)", >> >> > y : "sum(price)" >> >> > } >> >> > } >> >> > } >> >> > ' >> >> > >> >> > >> >> > If I want to write it in the format of this: >> >> > >> >> >> http://localhost:8983/solr/query?q=apple&json.facet={x:'avg(campaign_ult_defendant_cnt_is) >> '} >> >> , >> >> > how do I do? >> >> >> >> What problems do you encounter when you try that? >> >> >> >> If you try that URL with curl, be aware that curly braces {} are >> >> special globbing characters in curl. Turn them off with the "-g" >> >> option: >> >> >> >> curl -g " >> >> >> http://localhost:8983/solr/demo/query?q=apple&json.facet={x:'avg(price)'} >> " >> >> >> >> -Yonik >> >> >> > >