所有字段的默认搜索

jao*_*jao 3 lucene solr

当我在查询中包含一个字段时,我只能让Solr工作,例如:

http://localhost:8983/solr/collection1/select?q=lastname:johnson
Run Code Online (Sandbox Code Playgroud)

上面的查询返回大约18个结果.

如果不指定字段,是否应该可以使用Solr(/ Lucene)?如:

http://localhost:8983/solr/collection1/select?q=johnson
Run Code Online (Sandbox Code Playgroud)

我还尝试添加字段列表:

http://localhost:8983/solr/collection1/select?q=johnson&fl=cus_id%2Cinitials%2Clastname%2Cpostcode%2Ccity
Run Code Online (Sandbox Code Playgroud)

但所有这些查询都返回零结果.

这些是我的schema.xml中的字段:

<field name="cus_id" type="string" indexed="true" stored="true"/>
<field name="initials" type="text_general" indexed="true" stored="true" />
<field name="lastname" type="text_general" indexed="true" stored="true"/>
<field name="postcode" type="string" indexed="true" stored="true" />
<field name="city" type="text_general" indexed="true" stored="true"/>
Run Code Online (Sandbox Code Playgroud)

我不知道还有什么可以尝试的.有什么建议?

Jay*_*dra 7

对于Solr if not field,指定搜索在默认字段(df)上进行.
因此,当您搜索q = johnson并调试查询时,您会发现它在默认字段(通常是字段)上进行搜索text.
您可以所有字段复制到单个字段文本,并将其作为默认字段(如果不是默认字段),以便在默认字段中搜索所有搜索查询.
此外,fl列出将作为结果的一部分返回的字段,并且与执行搜索的字段无关.
使用dismax,您可以检查qf参数以指定具有可变增强的多个字段.