Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.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
Php 当q=<;时,Solr返回所有结果;空的>;_Php_Codeigniter_Search_Solr_Codeigniter Url - Fatal编程技术网

Php 当q=<;时,Solr返回所有结果;空的>;

Php 当q=<;时,Solr返回所有结果;空的>;,php,codeigniter,search,solr,codeigniter-url,Php,Codeigniter,Search,Solr,Codeigniter Url,我正在使用PHP Codeigniter framework来构建搜索应用程序 我有两页- 只有一个输入框的搜索页面 当用户在搜索页面中输入搜索词时,将显示结果的结果页面 问题是,除非我输入一个搜索词,否则它不会返回任何结果,并且url只会是”http://localhost:8080/search/?q=“而且它不会做任何事情。但当我输入一个搜索词,如“apple”作为示例时,它会重定向到搜索结果页面,匹配结果没有任何问题,url就会变成”http://localhost:8080/rdsea

我正在使用PHP Codeigniter framework来构建搜索应用程序

我有两页-

  • 只有一个输入框的搜索页面
  • 当用户在搜索页面中输入搜索词时,将显示结果的结果页面
  • 问题是,除非我输入一个搜索词,否则它不会返回任何结果,并且url只会是
    ”http://localhost:8080/search/?q=“
    而且它不会做任何事情。但当我输入一个搜索词,如“apple”作为示例时,它会重定向到搜索结果页面,匹配结果没有任何问题,url就会变成
    ”http://localhost:8080/rdsearch/?q=apple“


    我想实现的是-当用户没有在搜索页面中输入搜索项时,或者当q为空时,如
    ”http://localhost:8080/search/?q=“
    ,它应该直接指向结果页面并显示所有结果(类似于solr查询
    *:*

    可能还有其他解决方案,我可以向您提出以下两种解决方案

  • 您可以选中输入框。如果为空,则默认情况下,通过Solr URL将
    *:*
    作为输入传递
  • 或者,您可以修改select请求处理程序的solrconfig.xml。放
  • *:*

    询问时

    http://“localhost”:8080/solr/collection1/select?q=&wt=xml&indent=true&defType=dismax


    您可以看到,虽然我提供了
    q=
    ,但它将返回所有结果。因为它将接受q.alt查询,因为查询解析器现在是demax。欲了解更多信息,请

    谢谢!我检查了我的solrconfig.xml,发现q.alt已经设置为“:”,我不知道为什么在我使用的solr php客户端()中会忽略它。除此之外,我还必须在codeigniter中编辑我的控制器文件,包括如果$q为空,它必须返回所有内容