因此,根据这个http://yonik.com/solr-query-parameter-substitution/,可以在solrconfig中设置一个搜索处理程序
request handler defaults, appends, and invariants configured for the
handler may reference request parameters
我有以下查询适用于卷曲
curl http://localhost:7997/solr/vb_popbio/select -d 'q=*:*&fq=bundle:pop_sample_phenotype AND phenotype_type_s:"insecticide%20resistance" &rows=0&wt=json&json.nl=map&indent=true &fq=phenotype_value_type_s:${PFIELD}& &PGAP=5&PSTART=0&PEND=101&PFIELD="mortality rate"& json.facet = { pmean: "avg(phenotype_value_f)", pperc: "percentile(phenotype_value_f,5,25,50,75,95)", pmin: "min(phenotype_value_f)", pmax: "max(phenotype_value_f)", denplot : { type : range, field : phenotype_value_f, gap : ${PGAP:0.1}, start: ${PSTART:0}, end: ${PEND:1} } }'
我已将此查询转换为solrconfig.xml中的搜索处理程序配置,因此用户只需提供PFIELD,PGAP,PSTART和PEND参数.以下是处理程序的配置外观
<!--A request handler to serve data for violin plots (limited to IR assays)--> <requestHandler name="/irViolin" class="solr.SearchHandler"> <!-- default values for query parameters can be specified, these will be overridden by parameters in the request --> <lst name="defaults"> <str name="echoParams">explicit</str> <int name="rows">0</int> <str name="df">text</str> <str name="wt">json</str> <str name="json.nl">map</str> <str name="json.facet">{ pmean: "avg(phenotype_value_f)", pperc: "percentile(phenotype_value_f,5,25,50,75,95)", pmin: "min(phenotype_value_f)", pmax: "max(phenotype_value_f)", denplot : { type : range, field : phenotype_value_f, gap: ${PGAP:0.1}, start: ${PSTART:0}, end: ${PEND:1} } } </str> </lst> <lst name="appends"> <str name="fq">bundle:pop_sample_phenotype</str> <str name="fq">phenotype_type_s:"insecticide resistance"</str> <str name="fq">has_geodata:true</str> <str name="fq">phenotype_value_type_s:${PFIELD:"mortality rate"}</str> </lst> <lst name="invariants"> </lst> </requestHandler>
请注意,我为所有参数提供了默认值,否则SOLR将无法加载配置.问题是使用这样的查询
curl http://localhost:7997/solr/vb_popbio/irViolin?q=*:*& &PGAP=5&PSTART=0&PEND=101&PFIELD="mortality rate"
不管用. SOLR将正确读取请求参数(我可以在调试输出上看到它们),但会忽略它们并使用配置中的默认值.
SOLR版本是5.2.1.
我尝试将配置参数移动到默认值,追加或不变量,但没有任何工作.经过2天的研究,我几乎已经准备好放弃,而是在运行中构建整个查询.
任何帮助将不胜感激.
非常感谢
我认为(帖子)太旧了,但是使用搜索引擎我到了这个页面.一个简单的解决方案是逃避美元符号.之后,您应该达到理想的效果.例:
< str name =“json.facet”> { pmean:“avg(phenotype_value_f)”, pperc:“百分位数(phenotype_value_f,5,25,50,75,95)”, pmin:“min(phenotype_value_f)”, pmax:“max(phenotype_value_f)”, denplot:{ 类型:范围, 字段:phenotype_value_f, 差距:$${PGAP:0.1}, 开始:$${PSTART:0}, 结束:$${PEND:1} }}< / STR>