2017-01-19 10 views
0

나는 iOS Swift 개발자이고 내 앱에는 ElasticSearch을 사용하고 있습니다. 나는 typeES으로 선언하는 방법에 대해 머리를 쓰려고하는데, typedocument의 차이점은 무엇이며 object/data model과 가장 비슷합니다.ElasticSearch 유형을 만드는 방법

Swift에서 나는이 같은 object 또는 data model 만들 것 "조건"과 "이름"유형 String 모두 :

class Sneakers{ 
     var condition: String? 
     var name: String? 
} 

내가 2 개 속성 스니커즈라는 이름의 객체를 생성 말하고있다.

curl -XPOST <bonsai_url>/myIndexName //I'm using Heroku & Bonsai for my ES cluster 

내가 그때 어떻게에서 잃었어요 그래서

curl -XPOST <bonsai_url>/myIndexName/sneakerType 

같은 유형을 설정할 수 있습니다

내가 만들고 난 다음 사용 Index 내 ES를 설정하는 알고 내 운동화 데이터 모델을 검색 기준으로 사용하도록 sneakerType을 설정합니까? 내 애플 리케이션 내에서 사용자는 운동화 개체를 기반으로 신발을 검색 할 수 있습니다.

  1. type과 유형 및 문서 사이의 document
  2. 의 차이는 무엇 :

    나는 그것이 내 질문 ES에있을 것

    curl -XPOST <bonsai_url>/myIndexName/sneakerType -d ' 
    { 
        "sneakers": { 
         "properties": { 
         "condition": { 
          "type": string 
         }, 
         "name": { 
          "type": string 
         } 
         } 
        } 
    } 
    ' 
    

    의 라인을 따라 뭔가 알고 이는 데이터 모델과 같으며 fieldsproperties과 동일할까요? 내 index 이름과 type을 만든 후

  3. 는 어떻게 type 에 내 data model를 참조해야합니까 그것은 properties
  4. 내 마지막 질문에 대한 _mapping 무엇 것 그리고 내가 대신 내 curl 명령에 있음을 사용해야합니까?
+0

https://www.elastic.co/를 얻을 수 있습니다 : 지금은 내가 실행할 때 내 mappings 키 내부에 뭐가 있는지보고 싶은 키

curl -XPOST <BONSAI_URL>/firebase/_mappings/sneakers [email protected] 

guide/ko/elasticsearch/guide/current/mapping.html – blackmamba

답변

1

EStypeclass/data model/object과 동일합니다.

ES에서 fields은 클래스/데이터 모델/개체의 properties과 동일합니다.

document은 색인에서 실제로 검색되는 내용입니다. 내가 typesneakers으로 매핑하고 index 내부에 스니커 objects이 2 쌍인 경우 index은 그 안에 2 documents을 가질 것입니다.

Mappings은 설정하는 방법이다 indextype 있도록하고 내 object 또는 data model에 달합니다 properties 그리고 그것은이 properties을합니다.

은 내가 먼저 sneakerfile.json 라는 이름의 파일을 생성하고 내가 indexfirebase 이름 가지고 내가 지금

curl -XPOST <BONSAI_URL>/firebase 

을 실행하여 내 ES index을 만들어 단말기 내부에 그 다음의

{ 
    "sneakers": { 
     "properties": { 
     "condition": { 
      "type": "string" 
     }, 
     "name": { 
      "type": "string" 
     } 
     } 
    } 
} 
//sneakers is being treated like my Sneakers Swift class type 
//the properties condition & name are of type string just like my Swift's Sneaker's class's properties 

내부에이 코드를 추가 ES type을 만들고 이름을 sneakers으로하고 sneaker.json 파일을 사용하여 _mappings을 채 웁니다.

curl -XGET <BONSAI_URL>/firebase/_mappings?pretty 

나는

{ 
    "firebase" : { 
    "mappings" : { 
     "sneakers" : { 
     "properties" : { 
      "condition" : { 
      "type" : "string" 
      }, 
      "name" : { 
      "type" : "string" 
      } 
     } 
     } 
    } 
    } 
}