2016-05-15 1 views
0

関連する重みでユーザーが入力したタグから一連の画像を索引付けしようとしています。ペイロードとして入力されたウェイトを使用しようとしています。私はこれに続いてpostと辞書オブジェクトを作成しました。Solrnet有効搭載量 - 文書を追加するときの例外

私はどこ区切りフィールドcolors.Add(tag_name, (float)score);を追加することを確認していないか、それは私が記事で言及した辞書オブジェクトを使用するにはどうすればよいcolors.Add("color_p", "tag_name |score");

すべきですか?

Dictionary<string, float> colors = new Dictionary<string, float>(); 
          tags = TagUtils.GetTags(image, models["colors"]); 
          N = tags.TagNames.Count; 
          for (int n = 0; n < N; n++) 
          { 
           string tag_name = tags.TagNames[n]; 
           int score = tags.Scores[n]; 
           colors.Add(tag_name, (float)score); 
          } 

          docs_list.Add(new SolrDocument 
          { 
           _product_id = product_id, 
           _product_type = product_type, 
           _url = url, 
           _sku = sku, 
           _images = images.ToList<string>(), 
           _price = (float)price, 
           _name = name, 
           _color_p = colors,<--my payloads type field 
          }); 

schema.xmlは、次のようになります。

<field name="color_p" type="payloads" indexed="true" stored="true" multiValued="true"/> 

と定義は次のようになります。答えを投稿

<fieldtype name="payloads" stored="false" indexed="true" class="solr.TextField" > 
     <analyzer> 
      <tokenizer class="solr.WhitespaceTokenizerFactory"/> 
      <filter class="solr.DelimitedPayloadTokenFilterFactory" encoder="float" delimiter="|" /> 
     </analyzer> 
    </fieldtype> 

答えて

0

、それは私がしたように、誰が立ち往生役に立てば幸い:

*Dictionary<string, float> colors = new Dictionary<string, float>();* 

実際

Dictionary<string> colors = new Dictionary<string>(); 

なると、次のように追加する必要があります:

       tags = colorTags.Result; 
           N = tags.TagNames.Count; 
           for (int n = 0; n < N; n++) 
           { 
            string tag_name = tags.TagNames[n]; 
            int score = tags.Scores[n]; 
            if (score > 0) 
             colors.Add(tag_name + "|" + score); 
           } 
関連する問題