2012-08-28 2 views
0

solr이 중첩 문서를 지원합니까? 그리고 이런 종류의 문서를 만드는 더 좋은 방법이 있습니까?solr 색인 중첩 문서

<doc> 
    <field name="name">Mr. Test</field> 
    <field name="case"> 
     <field name="link">http://foo.com</field> 
     <field name="date">1-2-1234</filed> 
     <field name="title">My title</filed> 
    </field> 
    <field name="case"> 
     <field name="link">http://foo.com/2/</field> 
     <field name="date">1-2-1234</filed> 
     <field name="title">My title 2</filed> 
    </field> 
</doc> 

내가 가진 것은 여러 경우에 속한 사람입니다. 이 형태의 스키마는 solr와 합법적입니까? 다른 사람도 같은 경우의 일부일 수 있습니다. 따라서 관계형 데이터베이스의 작업처럼 보이지만이 프로젝트에 solr을 사용하고 있습니다.

답변

1

최신 버전의 schema.xml 상자로 문서

색인이 JSON

[ 
    { 
    "id": "1", 
    "title": "Solr adds block join support", 
    "content_type": "parentDocument", 
    "_childDocuments_": [ 
     { 
     "id": "2", 
     "comments": "SolrCloud supports it too!" 
     } 
    ] 
    }, 
    { 
    "id": "3", 
    "title": "Lucene and Solr 4.5 is out", 
    "content_type": "parentDocument", 
    "_childDocuments_": [ 
     { 
     "id": "4", 
     "comments": "Lots of new features" 
     } 
    ] 
    } 
] 

을 지원을 제공, u는 "제목이"입니다 여기에 사용지고 모든 필드를 추가해야합니다, "content_type", "comments". 매개 변수 "childDocuments"은 solr이주의를 기울이는 매개 변수이며 이것이 하위 문서 및 "content_type"임을 이해하는 매개 변수입니다. "parentDocument"는 solr이 상위 문서임을 인식하기위한 식별자입니다. 색인 생성 후이 Json을 쿼리하면

"*":"*" 

4 개의 문서가 모두 표시됩니다. 이제 Block and join query parsers의 도움으로 부모 또는 자녀 문서를 얻을 수 있습니다. 이것이 당신의 JSON 형식의 일부 오류가 있습니다

http://localhost:8983/solr/collection_test/select?q={!child%20of=%22content_type:parentDocument%22}title:lucene 

이 하나

http://localhost:8983/solr/collection_test/select?q={!parent%20which=%22content_type:parentDocument%22}comments:SolrCloud 
+0

를 조회 해보십시오. "_childDocuments_"뒤에 "["가 있어야합니다 : –

+0

@Lijo : thnks .. 내가 바꿨습니다. – Gunjan

+0

: - solr에서 아래처럼 인덱스를 만들려면 어떻게해야합니까? [{ "ID"에 "1" "COMPANY_ID": "1", "COMPANY_NAME": "COMPANY_1" "meta_categories"[ { "CAT_ID": "1", "cat_name" "패션" } { "CAT_ID": "2", "cat_name": "스포츠" } ] "main_categories"[ { "cat_name": "1", " cat_name ":"fashion " }, { "cat_name ":"2 ", "cat_name ":"sports " } ] –