phpsolrsolrjsolrnet

Efficient way for Solr PHP client configuration management in REST Service


I have some searchable data in Solr 6.6.6. My REST client is PHP. In order to search from Solr, I have to execute following (example) query from PHP

http://10.11.112.25:8983/solr/collection1/select?bf=recip(ms(NOW,date),3.16e-11,1,1)%5E2.2&boost=product(title1_depth,product(sum(arank,div(div(sum(cld2_score,cle_score),2),100),recip(pf_score,1,1,1)),sum(dup_stat,1)))&bq=group:ur_top_web%5E1.37&defType=edismax&fq=group:web%20OR%20group:ur_news*%20OR%20group:ur_blog%20OR%20group:ur_top_web*%20OR%20group:urpoetr*%20-pf_score:[0.7%20TO%201]%20OR%20NOT%20dup_stat1:[*%20TO%20*]&indent=on&mm=3&pf2=title%20content&pf3=title%20content&pf=title%20content&ps2=1&ps3=1&ps=10&q=%D9%BE%D8%A7%DA%A9%D8%B3%D8%AA%D8%A7%D9%86+%DA%A9%D8%A7+%D9%85%D8%B3%D8%AA%D9%82%D8%A8%D9%84&qf=title%20content&tie=0.4&wt=json&stopwords=true&lowercaseOperators=true&start=0&rows=10&hl=true&hl.snippets=5&hl.fl=title+content_t+content+id+url+summary&hl.method=original&hl.fragsize=100&f.summary.hl.fragsize=0&f.title.hl.fragsize=0&hl.requireFieldMatch=false&hl.alternateField=title+content_t+content+id+url+summary&hl.simple.post=</b>&hl.simple.pre=<b>&fl=title,content,url

In there a way to configure all these in Solr configurations (like XMLs etc.) and I just call a small size query from PHP. It will also help to control configuration parameters for multiple clients at one point.


Solution

  • You can create a custom search handler inside your Solr config. That allows you to specify static parameters that will be appended to the query made by your clients.

    <requestHandler name="/custom" class="solr.SearchHandler">
      <lst name="appends">
        <str name="bf">recip(ms(NOW,date),3.16e-11,1,1)^2.2</str>
        ...
      </lst>
    </requestHandler>
    

    You then query /custom instead of /select.