Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Solr 在haystack中同一字段的多个值上刻面_Solr_Django Haystack - Fatal编程技术网

Solr 在haystack中同一字段的多个值上刻面

Solr 在haystack中同一字段的多个值上刻面,solr,django-haystack,Solr,Django Haystack,我用的是干草堆和SOLR。我正试图在一个字段上实现对多个值的切面搜索。例如,我在“作者”字段上刻面 我想在“约翰”或“山姆”这两个字上刻上刻面。我如何格式化它的URL http://localhost:8000/search/?q=*&selected_facets=author_exact:john +OR+ selected_facets=author_exact:sam 如果要将生成的文档集限制为包含john或sam的文档集,请使用fq: fq=author:sam OR aut

我用的是干草堆和SOLR。我正试图在一个字段上实现对多个值的切面搜索。例如,我在“作者”字段上刻面

我想在“约翰”或“山姆”这两个字上刻上刻面。我如何格式化它的URL

http://localhost:8000/search/?q=*&selected_facets=author_exact:john +OR+ selected_facets=author_exact:sam

如果要将生成的文档集限制为包含
john
sam
的文档集,请使用
fq

fq=author:sam OR author:john
如果只想在某些值或查询上生成面,请使用:


您必须在视图/表单中使用或与shown()配合使用(具体实现取决于您使用的视图/表单)

因为获取选定面列表只涉及: self.request.GET.getlist('selected_facets')

您希望如何在url中实现这一点完全取决于您:

  • 您可以使用某种分隔符,然后将它们分开:
    localhost:8000/search/?q=*&selected\u facets=author\u exact:john\124; sam

    `对于选定面中的x: 字段名称,值=x.split(“:”,1)

    如果“|”不在值中: 继续
    值=x.split(“|”)`

  • 您也可以这样做:
    localhost:8000/search/q=*&selected\u facets=author\u exact:john&selected\u facets=author\u exact:sam

    刻面_dict=dict() 对于选定面中的x: 字段名称,值=x.split(“:”,1)
    facet_dict[字段名称].追加(值)

然后在干草堆中: sqs.窄(‘作者:(约翰或萨姆)’)


因此,基本上没有严格的规则/标准来说明如何在url中为facet实现多个值。

那么,您是否只希望facet中的
john
sam
的值,或者您想将结果集限制为仅包括字段中带有
john
sam
的文档吗?@MatsLindh我正在“author”字段上进行切面处理。我想为值“john”或“sam”创建结果。这是SOLR查询语法,但如何将其格式化为Haystack URL请求?对不起,我不熟悉Haystack。但是,无论如何,谢谢你的帮助!
fq=author:sam OR author:john
facet.query=author:sam OR author:john