나는 elasticsearch 쿼리 언어를 해킹하려고 시도하고 있으며, 지금까지는별로 잘하고 있지 않습니다.태그에 대한 ElasticSearch 쿼리
내 문서에는 다음과 같은 매핑이 있습니다.
{
"mappings": {
"jsondoc": {
"properties": {
"header" : {
"type" : "nested",
"properties" : {
"plainText" : { "type" : "string" },
"title" : { "type" : "string" },
"year" : { "type" : "string" },
"pages" : { "type" : "string" }
}
},
"sentences": {
"type": "nested",
"properties": {
"id": { "type": "integer" },
"text": { "type": "string" },
"tokens": { "type": "nested" },
"rhetoricalClass": { "type": "string" },
"babelSynsetsOcc": {
"type": "nested",
"properties" : {
"id" : { "type" : "integer" },
"text" : { "type" : "string" },
"synsetID" : { "type" : "string" }
}
}
}
}
}
}
}
}
주로 pdf 문서를 참조하는 JSON 파일과 유사합니다.
나는 집계를 사용하여 쿼리를 작성하려고 노력 해왔고 지금까지 훌륭하게 진행되고 있습니다. 그룹화 시점까지 (집계) rhetoricalClass
, 총 반복 수는 babelSynsetsOcc.synsetID
입니다. 심지어 전체 쿼리 결과를 그룹화하여도 같은 쿼리 일지라도 header.year
그러나 지금은 용어가 포함 된 문서를 필터링하고 동일한 쿼리를 수행하는 데 어려움을 겪고 있습니다.
rhetoricalClass
으로 그룹화하고 header.plainText
필드에 ["Computational", "Compositional", "Semantics"]
이 포함 된 문서 만 고려하면 어떻게 할 수 있습니까? 나는 equal
대신 contain
을 의미합니다!
난 그냥 표준 구조화 된 쿼리입니다
SELECT count(sentences.babelSynsetsOcc.synsetID)
FROM jsondoc
WHERE header.plainText like '%Computational%' OR header.plainText like '%Compositional%' OR header.plainText like '%Sematics%'
GROUP BY sentences.rhetoricalClass
예, 당신은 완전히 옳았습니다. 문서를 읽는 데 더 많은 노력을 기울여야하지만 공식적인 문서를 읽는 것은 매우 고통스러운 일입니다. 내 쿼리에서 누락 된 유일한 것은 중첩 된 필터였습니다. 어떻게 놓칠 수 있었는지 나는 알지 못합니다. 어쨌든, 당신의 공헌에 대해 대단히 감사합니다. – Mayhem