2016-06-08 45 views
0

文档我已经建立在elasticsearch索引的内容作为搜索如何附接在elasticsearch索引

this.client.CreateIndex("documents", c => c.Mappings(mp => mp.Map<DocUpload> 
       (m => m.Properties(ps => ps.Attachment 
            (a => a.Name(o => o.Document) 
              .TitleField(t => t.Name(x => x.Title).TermVector(TermVectorOption.WithPositionsOffsets)) 
              ))))); 

附件是BASE64索引之前编码。我无法搜索任何文档中的内容。 Base64编码会产生任何问题。任何人都可以帮忙吗?

浏览器响应是象

{ 
"documents": { 
    "aliases": {}, 
    "mappings": { 
    "indexdocument": { 
    "properties": { 
     "document": { 
     "type": "attachment", 
     "fields": { 
      "content": { 
      "type": "string" 
      }, 
      "author": { 
      "type": "string" 
      }, 
      "title": { 
      "type": "string", 
      "term_vector": "with_positions_offsets" 
      }, 
      "name": { 
      "type": "string" 
      }, 
      "date": { 
      "type": "date", 
      "format": "strict_date_optional_time||epoch_millis" 
      }, 
      "keywords": { 
      "type": "string" 
      }, 
      "content_type": { 
      "type": "string" 
      }, 
      "content_length": { 
      "type": "integer" 
      }, 
      "language": { 
      "type": "string" 
      } 
     } 
     }, 
     "documentType": { 
     "type": "string" 
     }, 
     "id": { 
     "type": "long" 
     }, 
     "lastModifiedDate": { 
     "type": "date", 
     "format": "strict_date_optional_time||epoch_millis" 
     }, 
     "location": { 
     "type": "string" 
     }, 
     "title": { 
     "type": "string" 
     } 
    } 
    } 
}, 
"settings": { 
    "index": { 
    "creation_date": "1465193502636", 
    "number_of_shards": "5", 
    "number_of_replicas": "1", 
    "uuid": "5kCRvhmsQAGyndkswLhLrg", 
    "version": { 
     "created": "2030399" 
    } 
    } 
}, 
"warmers": {} 
} 
} 
+0

我认为您的内容映射有问题。对我来说,它就像[this](http://s31.postimg.org/kulzmxom3/content_Mapping.png)可能是你的附件类定义出了问题。 – ASN

回答

0

我发现该溶液通过加入分析仪。

var fullNameFilters = new List<string> { "lowercase", "snowball" }; 
     client.CreateIndex("mydocs", c => c 
       .Settings(st => st 
         .Analysis(anl => anl 
         .Analyzers(h => h 
          .Custom("full", ff => ff 
           .Filters(fullNameFilters) 
           .Tokenizer("standard")) 
          ) 
          .TokenFilters(ba => ba 
           .Snowball("snowball", sn => sn 
            .Language(SnowballLanguage.English)))      
          )) 
         .Mappings(mp => mp 
         .Map<IndexDocument>(ms => ms 
         .AutoMap() 
         .Properties(ps => ps 
          .Nested<Attachment>(n => n 
           .Name(sc => sc.File) 
          .AutoMap() 
          )) 
         .Properties(at => at 
         .Attachment(a => a.Name(o => o.File) 
         .FileField(fl=>fl.Analyzer("full")) 
         .TitleField(t => t.Name(x => x.Title) 
         .Analyzer("full") 
         .TermVector(TermVectorOption.WithPositionsOffsets) 
         ))) 

         ))       
         );