查询解析器使用
查询解析器将Lucene查询解析成搜索语法
1. 指定查询解析器
- 使用defType参数进行修改
/select?defType=edismax&q=*:*
/select?defType=term&q=*:*
- Solr特殊语法{!...}
/select?q={!edismax}hello world
/select?q={!term}hello world
/select?q={!edismax}hello world OR {!lucene}title:"my title"
2. 局部参数
局部参数为特定上下文提供定制化请求参数,以{!开头,以}结尾。
{!param1=value1 param2=value2 … paramN=valueN}
/select?q=hello world&defType=edismax&qf=title^10 text&q.op=AND
等价
/select?q={!defType=edismax qf="title^10 text" q.op=AND}hello world
3. 参数值
局部参数声明的值就是要传递给查询器的值,特殊键v
/select?q={!defType=edismax qf="title^10 text" }hello world
等价
/select?q={!defType=edismax qf="title^10 text" v="hello world" }
4. 参数解引用
提供查询中任意变量替换
/select?q={!edimax v=$userQuery}&userQuery="hello world"
通过将eDisMax查询解析器的传入值指定为解引用参数$userQuery,该值可以在请求的其他位置。
5. 查询和过滤器
参数q与fq:q表示查询;fq表示过滤器查询,查询结果后的过滤,可以说跟SQL的where差不多。
/select?q=hello world&fq=world
查询里,q只有一个,fq可以有多个。