SOLR使用CONCAT函数查询从字段中丢失了一些单词-如何使其处理所有单词?

问题描述 投票:0回答:1

我有一个SOLR文件:

{
    "id": "Test1",
    "MyInt": 100500,
    "FirstString": ["Test First String"],
    "SecondString": ["Test Second String"]
}

此核心的托管模式是:

...
  <field name="MyInt" type="plong" /> 
  <field name="FirstString" type="text_general" /> 
  <field name="SecondString" type="text_general" /> 
...

类型“ text_general”-这是用于正确的搜索。

我需要在/ select中合并两个文本字段。我创建了这样一个请求:

http://localhost:8983/solr/testcore/select?q=*:*&fl=Result:concat(FirstString,';',SecondString)

希望在结果中看到一些类似的文字:

Result:"Test First String;Test Second String"

但是实际上,SOLR会删除部分单词,并且每个字段仅保留1个单词​​。也许最重要的事情要寻找:

Result:"First;Second"

[不提供我在/ select中将wt = json更改为wt = csv的信息,我知道此功能,但在这种情况下不适合。

请告知SALS如此奇怪行为的原因是什么?

也许这是由于数据以multiValued = true存储在type =“ text_general”字段中的事实?我使用type =“ string”字段进行了实验-问题重复出现。

我不明白如何使SOLR接受concat函数查询中text_general字段中的所有单词?

function solr concat
1个回答
0
投票

您对此的假设是因为使用text_general字段类型是正确的;使用concat时,只有第一个令牌将从字段中返回。但是,您是说使用string字段也不起作用-是错误的。当使用string字段类型时(即未进行任何处理且文本被逐字存储为单个标记),其行为与您的要求相同:

{
  "responseHeader":{
    "zkConnected":true,
    "status":0,
    "QTime":4,
    "params":{
      "q":"*:*",
      "fl":"FirstField_string, LastField_string, Result:concat(FirstField_string,';',LastField_string)",
      "_":"1581267948122"}},
  "response":{"numFound":1,"start":0,"docs":[
      {
        "FirstField_string":"Test First String",
        "LastField_string":"Test Second String",
        "Result":"Test First String;Test Second String"}]
  }}

字段名称更改只是因为我尝试使用您的原始字段名称。这要求字段为multiValued="false"

© www.soinside.com 2019 - 2024. All rights reserved.