在Solr文档中存储和搜索动态键值对 [英] Storing and searching dynamic key value pairs in Solr document

查看:460
本文介绍了在Solr文档中存储和搜索动态键值对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要存储和索引附加了特定Solr文档的键值对。例如,可能有一个可变数量的标签(标签)附加到solr文档,每个标签名称都有一个整数以及它作为它的值。

I need to store and index key value pairs attached with a particular Solr document. For eg, there might be a variable number of tags(labels) attached to a solr document with each tag name having an integer along with it as a value for it.

   <doc>
     <id>1001</id>
     #dymanic tags attached
     php=>10
     web=>2
     programming=>12
     mysql=>10

    </doc>  

因此,当我搜索php时,此文档应显示在搜索结果中,我应该能够读取该特定文档的值(例如,其值为10)。如何为此创建架构以及如何存储它。另外我如何使用REST api搜索它?

So when I search for "php" this document should showup in the search results and I should be able to read its value for that particular document (in case of example its value is 10). How do I create a schema for this and how do i store this. Also how do I search for it using the REST api?

推荐答案

对于动态字段,您需要将它们添加为关键字获取计数以及使它们可搜索的值。

With dynamic fields, you would need to add them as a key for getting the count and as well as values for making them searchable.

相反,您可以尝试 -

Instead you can try -

添加它们是语言和计数的多值字段。

Add them as the multivalued field for both the languages and the counts.

语言字段将保存语言的值,也可以作为可搜索的字段。

The language field will hold the values of the languages, and can also serve as the searchable fields.

<field name="language" type="text" indexed="true" stored="true" multiValued="true"/>

将语言计数添加为其他多值字段,并保留订单。

Add the language count as the other multivalued fields, with the maintained order.

<field name="language_count" type="int" indexed="false" stored="true" multiValued="true"/>

在响应中,您将有两个用于语言和language_counts的数组,您可以映射计数客户端的语言位置。

In the response, you would have two arrays for language and language_counts and you can map the count for the language on the client side by the position.

这篇关于在Solr文档中存储和搜索动态键值对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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