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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?