Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在solr中索引词典_Solr - Fatal编程技术网

如何在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

我在solr
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()