Haskell (Aeson)에서 Elasticsearch로 Http 요청을하려고합니다.Haskell에서 "같은 데이터"를 두 번 사용하여 쿼리 요청
{
"query": {
"function_score": {
"query": {
"bool": {
"should": [
{"term": {"word_n_gram": "str"}},
{"term": {"word_n_gram": "not"}}
]
}
},
"functions": [
{
"script_score": {
"script": {
"lang": "groovy",
"file": "test-score",
"params": {
"boostBy": {
"str": 1,
"not": 1
}
}
}
}
}
]
}
}
}
을 그리고 제대로 작동합니다
Elasticsearch의 몸은 그렇게 보인다.
그래서 나는 하스켈에서 "해당"를 만들어 : 요점은, 하스켈, 나는 두 번 "쿼리"를 가질 수있다
data QueryRequest = QueryRequest {
query :: Query
} deriving (Eq, Generic, Show)
instance ToJSON QueryRequest
data Query = Query {
function_score :: FunctionScore
} deriving (Eq, Generic, Show)
instance ToJSON Query
data FunctionScore = FunctionScore {
queryIn :: QueryIn
, functions :: [Functions]
} deriving (Eq, Generic, Show)
instance ToJSON FunctionScore
data QueryIn = QueryIn {
bool :: BoolQuery
} deriving (Eq, Generic, Show)
instance ToJSON QueryIn
data BoolQuery = BoolQuery {
should :: [ShouldQuery]
} deriving (Eq, Generic, Show)
등등을 ...
FailureResponse {responseStatus = Status {statusCode = 400, statusMessage = "Bad Request"}, responseContentType = application/json;charset=UTF-8, responseBody = "{\"error\":{\"root_cause\":[{\"type\":\"parsing_exception\",\"reason\":\"no [query] registered for [queryIn]\",\"line\":1,\"col\":39}],\"type\":\"parsing_exception\",\"reason\":\"no [query] registered for [queryIn]\",\"line\":1,\"col\":39},\"status\":400}"}
논리 오류입니다 : 내가 요청을 만들고 있어요, 그리고 Elasticsearch이 query
두 번을 기다리고 있기 때문에, 내가 queryIn
을 쓴 이유하지만, 선언은,이 오류가 발생합니다. 내부
toElasticSearchQuery :: T.Text -> RW.QueryRequest
toElasticSearchQuery word =
RW.QueryRequest {
RW.query = RW.Query {
RW.function_score = RW.FunctionScore {
RW.queryIn = RW.QueryIn {
RW.bool = RW.BoolQuery {
RW.should = toShouldQueryList (splitInNGrams word)
}
},
RW.functions = [
RW.Functions {
RW.scriptScore = RW.ScriptScore {
RW.script = RW.Script {
RW.lang = scriptLang,
RW.file = scriptFile,
RW.params = RW.Params {
RW.boostBy = fixGramConter (splitInNGrams word)
}
}
}
}
]
}
}
}
물론, 내가 쓸 수 없습니다 RW.query :하지만
나는이 방법으로 "RequestQuery"를 만들 .... 내가 그것을 고칠 수있는 방법을 모른다 RW.FunctionScore. 어떻게 해결할 수 있을지 모르겠다. 응답은 문제가되지 않지만 요청의 경우 문제가된다.어쩌면 누군가가 전에 그런 시도를했을 수도 있습니다.