dongzuoyue6556 2014-02-01 01:55
浏览 22
已采纳

使用SolrBundle在Symfony2中的Solr区分大小写

I've been googling all day to try and figure out how to set a query to be not case sensitive. I'm currently using Florian Semm's SolrBundle at this github page. I thought it would be as simple as saying $query->setCaseSensitive(false); or something similair, but apparently not. Any ideas? I'm using Solr4.1.6 and Symfony 2.4.1 if that makes any difference.

This is what I have so far...

$solrQuery = $this->get('solr.client.default')
                  ->createQuery('MyBundle:User')
                  ->addSearchTerm('name', $queryString)
                  ->addSearchTerm('surname', $queryString);
$solrQuery->setUseWildcard(true);

$entities = $solrQuery->getResult(); 

This obviously returns correctly, but only if the case of the query is correct. For example, searching for "Thom" returns the entity containing "Thomas", but "thom" does not.

Thanks for any help!

  • 写回答

1条回答 默认 最新

  • duanke1984 2014-02-01 12:50
    关注

    You might want to look the solr Schema as there could be analyzers configured in there. Specifically if LowerCaseFilterFactory is configured in your schema it will convert the text terms to lowercase while the content is being indexed, same is possible in query time. Example below is what you might want to look for.

    <fieldtype name="text" class="solr.TextField">
      <analyzer>
        ......
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
    </fieldtype>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器