如何在solr中索引词典
我在solr如何在solr中索引词典,solr,Solr,我在solrschema.xml中有一个字段,course\u category\u score。我希望此字段在solr中作为字典索引。例如: course_category_score{ 'engineering': 1.6, 'management':2.0 } 我也希望该字段用于排序。为了索引任何对象(包括字典),该对象可以JSON序列化并作为普通字符串字段索引 doc.Add("FieldName", Newtonsoft.Json.JsonConv
schema.xml
中有一个字段,course\u category\u score
。我希望此字段在solr中作为字典索引。例如:
course_category_score{
'engineering': 1.6,
'management':2.0
}
我也希望该字段用于排序。为了索引任何对象(包括字典),该对象可以JSON序列化并作为普通字符串字段索引
doc.Add("FieldName", Newtonsoft.Json.JsonConvert.SerializeObject(dictionary));
字段定义:
<field
name= "FieldName"
type= "string"
stored= "true"
indexed= "false"
required= "false"
/>
solrURL=pysolr.Solr('http://localhost:8983/solr/,超时=100)
dictData={}#你的任何字典
solrURL.add([dictData])
solrURL.commit()
这将是对给定字典的无模式摄取。谢谢zorze,但我需要添加字典而不使用pysolr。希望直接从solr DataImportHandler完成。
solrURL = pysolr.Solr('http://localhost:8983/solr/<SchemaName>', timeout=100)
dictData = {} #Your any dictionary
solrURL.add([dictData])
solrURL.commit()