Tim*_*ely 13 lucene solr localsolr
我是使用Solr的新手,我必须遗漏一些东西.
我还没有在示例模式中触及太多,我导入了一些示例数据.我也成立了LocalSolr,这似乎运作良好.
我的问题只是Solr一般的查询.我有一个文件,名称字段设置为汤姆. 我一直在查看配置文件,我无法弄清楚我哪里出错了.索引和存储了一堆字段,我可以看到管理员中的值,但我无法查询正常工作.我尝试了各种查询(http://server.com/solr/select/?q=value),结果如下:
**Query:** ?q=tom
**Result:** No results
**Query:** q=\*:\*
**Result:** 10 docs returned
**Query:** ?q=*:tom
**Result:** No results
**Query:** ?q=name:tom
**Result:** 1 result (the doc with name : tom)
Run Code Online (Sandbox Code Playgroud)
我希望第一个案例(?q=tom)有效.任何可能出错的输入以及我如何纠正它都将受到赞赏.
Mau*_*fer 14
设置<defaultSearchField>到name你的schema.xml
在
<defaultSearchField>解析查询,以确定哪些字段名称应该在明确的字段名称尚未使用的查询进行搜索时所采用的Solr.
您可能还想查看(e)dismax.
我刚刚遇到了类似的问题......即我已经定义了多个字段(schema.xml中不存在)来描述我的文档,并且想要搜索/查询文档的多个字段,而不仅仅是一个他们(就像上面提到的例子中的"名字").
为了实现这一点,我创建了一个新字段("compoundfield"),然后我将/ copyField放入我定义的字段(就像Solr发行版附带的schema.xml文档中的"text"字段).这导致如下所示:
coumpoundfield定义:
<field name="compoundfield" type="text_general" indexed="true" stored="false" multiValued="true"/>
Run Code Online (Sandbox Code Playgroud)
defaultSearchField:
<!-- field for the QueryParser to use when an explicit fieldname is absent -->
<defaultSearchField>compoundfield</defaultSearchField>
<!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
<solrQueryParser defaultOperator="OR"/>
<!-- copyField commands copy one field to another at the time a document
is added to the index. It's used either to index the same field differently,
or to add multiple fields to the same field for easier/faster searching. -->
<!-- ADDED Fields -->
<copyField source="field1" dest="compoundfield"/>
<copyField source="field2" dest="compoundfield"/>
<copyField source="field3" dest="compoundfield"/>
Run Code Online (Sandbox Code Playgroud)
这对我来说很好,但我不确定这是否是进行这种"多场"搜索的最佳方式...
干杯!