-1
나는 내 mongodb에서 다음 json 구조를 가지고있다.'LIKE'문을 사용하여 mongoengine의 객체를 필터링하는 방법은 무엇입니까?
{
"country": "spain",
"language": "spanish",
"words": [
{
"word": "hello1",
....
},
{
"word": "hello2",
....
},
{
"word": "test",
....
},
]
}
나는 모든 사전을 특정 부분 문자열이 일치하는 '단어'목록 안에 넣으려고합니다. 일치를위한
다음 쿼리에만 작동 'hello1'와 'hello2': 나는 문자열이있는 경우
예를 들어, 내 문서의 단어로 두 개의 사전을 제공 mongoengine를 사용하여 쿼리하는 방법 다음, '그러는' 단어는 부분 문자열이 아닙니다. 어레이에서의 조건과 일치하는 첫 번째 요소를 반환 (mongoengine에 match
) $elemMatch
사용
data = Data.objects.filter(words__match={"word":"hel"})
// data is empty in this case([])