2014-01-22 2 views
0

Elastic Search/NEST를 처음 사용했습니다. 현재 다음 클래스를 매핑하려고합니다.NEST에서 매핑하는 동안 StackOverflowException이 발생했습니다.

[ElasticType(
    Name = "zData", 
    SearchAnalyzer = "standard", 
    IndexAnalyzer = "standard", 
    DateDetection = false, 
    NumericDetection = true 

)] 
public class zData { 

    [ElasticProperty(Type = FieldType.string_type)] 
    public String zName { 
     get; 
     set; 
    } 
    [ElasticProperty(Type = FieldType.string_type)] 
    public String zType { 
     get; 
     set; 
    } 

    [ElasticProperty(Type = FieldType.nested)] 
    public List<zData> Items { 
     get; 
     set; 
    } 

    [ElasticProperty(Type = FieldType.string_type)] 
    public String Value { 
     get; 
     set; 
     } 
    } 

먼저 완전히 자동으로 매핑하려고했습니다.

var r = IndexClient.MapFluent<zData>(z => z 
      .TypeName("zData") 
      .IndexNames("testdata") 
      .IgnoreConflicts() 
      .IndexAnalyzer("standard") 
      .SearchAnalyzer("standard") 
      .DateDetection(false) 
      .NumericDetection(false) 
      .MapFromAttributes() 
      .DisableAllField(false) 
      .DisableIndexField(false) 
      .DisableSizeField(false) 
      .Dynamic() 
      .Enabled() 
      .Path("full") 
      .Properties(props => props 
       .Object<zData>(s => s 
        .Name(p => p.Items.First()) 
        .Dynamic() 
        .Enabled() 
        .IncludeInAll() 
        .MapFromAttributes() 
        .Path("full") 
        .Properties(pprops => pprops 
         .String(ps => ps.Name(p => p.zName).Index(FieldIndexOption.not_analyzed)) 
         .String(ps => ps.Name(p => p.zType).Index(FieldIndexOption.not_analyzed)) 
         .String(ps => ps.Name(p => p.Value).Index(FieldIndexOption.not_analyzed)) 
        ) 
       ) 
       .NestedObject<zData>(s => s 
        .Name(p => p.Items.First()) 
        .Dynamic() 
        .Enabled() 
        .IncludeInAll() 
        .IncludeInParent() 
        .IncludeInRoot() 
        .MapFromAttributes() 
        .Path("full") 
        .Properties(pprops => pprops 
           .String(ps => ps.Name(p => p.zName).Index(FieldIndexOption.not_analyzed)) 
           .String(ps => ps.Name(p => p.zType).Index(FieldIndexOption.not_analyzed)) 
           .String(ps => ps.Name(p => p.Value).Index(FieldIndexOption.not_analyzed)) 
        ) 
       ) 
      ) 
     ); 

나는이 매핑 내 경우에 편리합니다 있는지 확실하지 않습니다 : 나중에 나는 주로 GitHub의에서 테스트 프로젝트의 것과 같은 인 자신에 의해 매핑을 만들려고.

Process is terminated due to StackOverflowException 

프로그램을 닫은 후, 나는 예외가 mscorlib.dll에서 일어난 것으로, 비주얼 스튜디오에서 메시지를 얻을 : 내가 얻는 예외는 다음과 같습니다.

저는 문제가 무한 루프 때문에 발생한다는 것을 알고 있습니다. zData 객체는 zData의 목록을 가질 수 있으며, 각 목록은 zData의 목록을 가질 수 있습니다. 그러나 NEST가 첫 번째 목록보다 더 깊게 가지 않도록 명령하는 명령이 있습니까? 예를 들면 다음과 같습니다. 어쩌면 누군가가 현재처럼 융통성있는 zData의 대안 구조를 알고있을 것입니다. 그러나 더 많은지도를 저장합니까?

EDIT1 : 새로운 매핑

var mapping = IndexClient.MapFluent<zData>(m => m 
      .IgnoreConflicts() 
      .Dynamic() 
      .Enabled() 
      .IncludeInAll() 
      .DisableAllField(false) 
      .DisableIndexField(false) 
      .DisableSizeField(false) 
      .Path("full") 
      .AnalyzerField(a => a 
       .SetPath(p => p.zName) 
       .SetIndexed() 
      ) 
      .TypeField(t => t 
       .SetIndexed() 
       .SetStored() 
      ) 
      .Properties(p => p 
       .String(s => s 
        .Name(n => n.zName) 
        .IndexName("name") 
        .IncludeInAll() 
        .Index(FieldIndexOption.analyzed) 
        .SearchAnalyzer("standard") 
        .Store() 
       ) 
       .String(s => s 
        .Name(n => n.zType) 
        .IndexName("ztype") 
        .IncludeInAll() 
        .Index(FieldIndexOption.analyzed) 
        .SearchAnalyzer("standard") 
        .Store() 
       ) 
       .String(s => s 
        .Name(n => n.Value) 
        .IndexName("value") 
        .IncludeInAll() 
        .Index(FieldIndexOption.analyzed) 
        .SearchAnalyzer("standard") 
        .Store() 
       ) 
       .NestedObject<zData>(z => z 
        .Name(n => n.Items.First()) 
        .Dynamic() 
        .Enabled() 
        .IncludeInAll() 
        .Path("full") 
        .Properties(pp => pp 
         .String(ps => ps 
          .Name(na => na.zName) 
          .Index(FieldIndexOption.not_analyzed) 
         ) 
        ) 
       ) 
      ) 
     ); 

답변

0

MapFromAttributes() 재귀 기본적으로 더 recursionLimit가없는 완전한 객체 그래프를 안내합니다.

운 좋게도 MapFromAttributes(maxRecursion:1)과 함께 하나를 줄 수 있습니다.

+0

고마워요, 내가 무엇을 찾고 있었는지, 예외는 여전히 있습니다 : ( – snowiow

+0

여러 장소의 속성에서지도를 호출한다는 사실을 알았습니다. 모두 업데이트 했습니까? –

+0

예. 내가 한 일이 – snowiow

관련 문제