如何在apache solr中以原始嵌套形式检索json? [英] How to retrieve json in original nested form in apache solr?

查看:270
本文介绍了如何在apache solr中以原始嵌套形式检索json?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为文本搜索使用 apache solr 。我有嵌套文档结构。这是 one.json file:

  {
ID:1,
info:{
first_name:John,
last_name:Doe,
gender:male
}
}

我创建了一个solr核心并发布了 one.json in it.Solr 索引并展平了上述文档的嵌套结构,我猜想以下面的形式可以更好地建立索引: p>

  {
id:[1],
info.first_name:[John ],
info.last_name:[Doe],
info.gender:[male]
}

现在,当我进行搜索查询时,结果以扁平形式



对于我的要求,我想要原始嵌套形式的响应json

Solr如何实现?

有没有一些工具可以与Solr一起使用来获取原始的嵌套json ? >添加:



我正在使用 solr 6.3.0 。当我将json文件添加到内核时,solr 自动索引json文件。一个 managed-schema.xml 由solr生成。



这是部分managed-schema.xml 其中定义了字段:

 < field name =_ root_type =stringdocValues =falseindexed =truestored =false/> 
< field name =_ text_type =text_generalmultiValued =trueindexed =truestored =false/>
< field name =_ version_type =longindexed =falsestored =false/>
< field name =idtype =stringmultiValued =falseindexed =truerequired =truestored =true/>
< field name =info.first_nametype =strings/>
< field name =info.gendertype =strings/>
< field name =info.last_nametype =strings/>


解决方案

srcField 参数,如参考指南中有关处理的部分所述自定义JSON 。注意嵌套文档将作为单个文档建立索引的限制。



如果要使用已发布的模式测试techtech示例,则会配置srcField。 / p>

I am using apache solr for text search. I have nested document structure. This is one.json file :

{
"id": "1",
"info": {
       "first_name": "John",
       "last_name": "Doe",
       "gender": "male"
        }
}

I created a solr core and posted one.json in it.Solr indexed and flattened the above document's nested structure , I guess for better indexing in following form:

{
    "id":["1"],
    "info.first_name":["John"],
    "info.last_name":["Doe"],
    "info.gender":["male"]
}

Now, when I make the search query,the result is in flattened form.

For my requirement, I want the response json in original nested form.

How can this be achieved in Solr ? Is there some tool that I can use with Solr to get the original nested json while making search?

Addition:

I am using solr 6.3.0. When I added the json file to the core, solr automatically indexed the json file. A managed-schema.xml was generated by solr.

Here is a portion of managed-schema.xml where fields are defined:

<field name="_root_" type="string" docValues="false" indexed="true" stored="false"/>
  <field name="_text_" type="text_general" multiValued="true" indexed="true" stored="false"/>
  <field name="_version_" type="long" indexed="false" stored="false"/>
  <field name="id" type="string" multiValued="false" indexed="true" required="true" stored="true"/>
  <field name="info.first_name" type="strings"/>
  <field name="info.gender" type="strings"/>
  <field name="info.last_name" type="strings"/>

解决方案

This may be possible with srcField parameter as described in the Reference Guide section on processing custom JSON. Notice the limitation that your nested document will be indexed as a single document.

The techproduct example has the srcField configured, if you want to test it with a shipped schema.

这篇关于如何在apache solr中以原始嵌套形式检索json?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆