1)搜索不到结果
schema.xml中默认搜索字段的配置:
q=flysnowxf这种不带字段的搜索,默认只搜索text字段。如果我要搜索name字段怎么样?使用
q=name:flysnowxf
2)bad request
客户端错误提示:
org.apache.solr.common.SolrException: Bad Request
Bad Request
request: http://localhost:8080/solr/update?wt=xml&version=2.2
服务端错误提示:
org.apache.solr.common.SolrException: ERROR:unknown field 'test'
原因是我add操作时,使用了
test字段在schema.xml中不存在,所以需要把test字段添加进去:
3)中文乱码
使用solr的admin查询或者solr客户端查询时,查询条件可能出现中文乱码,比如:
schema.xml中默认搜索字段的配置:
<defaultSearchField>text</defaultSearchField>q=flysnowxf这种不带字段的搜索,默认只搜索text字段。如果我要搜索name字段怎么样?使用
<copyField source="name" dest="text"/>该语句意思是把name字段的值也复制到text字段中,这样就可以搜索了。否则必须显式指定q=name:flysnowxf
2)bad request
客户端错误提示:
org.apache.solr.common.SolrException: Bad Request
Bad Request
request: http://localhost:8080/solr/update?wt=xml&version=2.2
服务端错误提示:
org.apache.solr.common.SolrException: ERROR:unknown field 'test'
原因是我add操作时,使用了
doc.addField("test", "bad request");test字段在schema.xml中不存在,所以需要把test字段添加进去:
<field name="test" type="text" indexed="true" stored="true"/>3)中文乱码
使用solr的admin查询或者solr客户端查询时,查询条件可能出现中文乱码,比如:
<lst name="params">
<str name="indent">on</str>
<str name="start">0</str>
<str name="q">ç</str>
<str name="rows">10</str>
<str name="version">2.2</str>
</lst>解决办法是在web服务器对get请求配置编码格式,tomcat的方式为:<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"/>
本文介绍了Apache Solr搜索引擎中的常见问题及解决方案,包括如何配置默认搜索字段、处理客户端错误和中文乱码问题等。
275

被折叠的 条评论
为什么被折叠?



