当文档值=true 时,小写筛选器工厂不起作用



我试图使用Solr实现不区分大小写的排序,并面临这个问题。

(复制)

....But When I get search result its not sorted case insensitive. It gives all camel case result first and then all lower case
If I m having short names
Banu
Ajay
anil
sudhir
Nilesh
It sorts like Ajay, Banu, Nilesh, anil, sudhir
...................

我遵循了解决方案,并在我的solr schema.xml文件中做了以下更改(仅显示相关字段和字段类型):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<schema name="autoSolrSchema" version="1.5">
	<types>
		...............
		<fieldType class="org.apache.solr.schema.TextField" name="TextField">
			<analyzer>
				<tokenizer class="solr.KeywordTokenizerFactory"/>
				<filter class="solr.LowerCaseFilterFactory"/>
			</analyzer>
		</fieldType>
		.............
	</types>
	<fields>
	.................
		<field indexed="true" multiValued="false" name="name" stored="true" type="TextField" docValues="true" />
	................	
	</fields>
	<uniqueKey>id</uniqueKey>
	</schema>

但这并没有解决排序问题。因此,我从字段定义中删除 docValues="true"并再次尝试。这次排序工作得很好,但是我必须在查询中指定useFieldCache=true

为什么solr.LowerCaseFilterFactory不与docValues="true"一起工作?

是否有其他方法使不区分大小写的排序工作,而不删除docValues="true"和指定useFieldCache=true ?

更新:

我遵循了ericLavault的建议,实现了Update Request处理器。但现在我面临着以下问题:

1)我们正在使用dse搜索。因此,按照本文指定的方法执行。

当前表模式:

CREATE TABLE IF NOT EXISTS test_data(
    id      UUID,   
    nm      TEXT,   
    PRIMARY KEY (id)

Solr:

 Solr schema :
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<schema name="autoSolrSchema" version="1.5">
	<types>
		<fieldType class="org.apache.solr.schema.UUIDField" name="UUIDField"/>
		<fieldType class="org.apache.solr.schema.StrField" name="StrField"/>
	</types>
	<fields>
		<field indexed="true" multiValued="false" name="nm" stored="true" type="StrField" docValues="true"/>
		<field indexed="true" multiValued="false" name="id" stored="true" type="UUIDField"/>
		<field indexed="true" multiValued="false" name="nm_s" stored="true" type="StrField" docValues="true"/>
	</fields>
	<uniqueKey>id</uniqueKey>
</schema>

按照建议,我将nm转换为小写,并使用更新请求处理器插入nm_s。然后重新加载模式并重新索引。但是当使用select nm from test_data where solr_query='{"q": "(-nm:(sssss))" ,"paging":"driver","sort":"nm_s asc"}';

查询时

我得到以下错误:

...enable docvalues true n reindex or place useFieldCache=true...

2)如何确保值nm_s被正确更新?有什么方法可以看到nm_s的值吗?

3)为什么我得到上述错误,即使docValues是启用的?

这个问题可能来自DocValues最初被设计为支持未分析类型的事实。不支持TextField:

DocValues仅对特定字段类型可用。类型决定底层Lucene docValue类型使用。可用的Solr字段类型有:

  • StrField和uidfield:
    • 如果字段是单值(即,多值为false), Lucene将使用SORTED类型。
    • 如果字段是多值的,Lucene将使用SORTED_SET类型。
  • 任何Trie*数字字段,日期字段和枚举字段。
    • 如果字段是单值(即,多值为false), Lucene将使用NUMERIC类型。
    • 如果字段是多值的,Lucene将使用SORTED_SET类型。

(引自https://cwiki.apache.org/confluence/display/solr/DocValues)

Solr Jira在为TextField (Solr -8362)添加docValues支持时存在一个问题,但仍然打开且未分配


为了在不删除docValues="true"的情况下使不区分大小写的排序工作,您将不得不使用字符串字段类型(solr.StrField),但是由于您不能使用字符串类型定义任何<analyser>,您将需要一个更新请求处理器来小写输入流(或等效于在将数据发送到Solr之前预处理字段内容)。

如果你希望你的字段被标记搜索排序使用DocValues,你可以使用一个copyField基于你的实际文本字段(没有DocValues)和一个字符串字段排序(处理小写和启用DocValues)。

最新更新