2013-03-05 1 views
1

모델 :Elasticsearch 매핑은 레일 키 - 값 저장소에서 속성을 포함하지 않는

class Item 
    store :socket_store, accessors: [:sockets, :socket_count, :socket_link_count] 
end 

매핑 :

mapping do 
    indexes :id,     key: "value", index: :not_analyzed 
    indexes :sockets,    type: "object" 
    indexes :socket_count,   type: "integer" 
    indexes :socket_link_count,  type: "integer" 
end 

그러나 여기가 내 실제 지수는 모습입니다 같은 :

socket_cout과 2 개의 속성은 다음의 루트에 없습니다. 마치 완전히 무시 된 것처럼 매핑.

다른 이름으로 메소드를 작성하여 to_indexed_json에 추가 할 수 있다는 것을 알고 있지만, 그것이 작동해야한다고 추측했을 것입니다.

+0

이름 불일치가 있습니까? 그것이 영향을 미치는지 모른다. 'linked_socket_count'! = socket_link_count' – aledalgrande

+0

아, 죄송합니다, 저는 방금 필드 이름을 바꾸었지만 그 당시에는 정확했습니다. 문제가 해결되었습니다. – Robin

+0

@ karmi 어떤 아이디어? :디 – Robin

답변

1

좋아, 알았다.

def to_indexed_json 
    to_json(include: [:stats], exclude: [:sockets_store], methods: [:socket_count, :socket_link_count, :sockets]) 
end 

을 그리고 그것 뿐이다 : 키 - 값 저장소의 접근은 실제 속성은 Item 모델에없는 때문에

, 그들은 to_indexed_json 방법의 방법으로 추가 할 필요가!