Uh oh!
There was an error while loading. Please reload this page.
Initial search service DSL implementation - #2136
Conversation
Add basic range implementation. Do some fixes.
d7d788a to
6eef884CompareAdd simple match function implementation. Add temp ugly workaround for issue with shapeless Folder.
Allow for empty fc query, that is interpreted as `match_all` query. Return max_score with response to keep it consistent with current search result.
9e5d990 to
f9229acCompare| val withQuery = searchQuery match { | ||
| case SearchPayload.es(query, _) ⇒ (_: SearchDefinition) rawQuery Json.fromJsonObject(query).noSpaces | ||
| case SearchPayload.fc(query, _) ⇒ | ||
| // TODO: this is really some basic and quite ugly interpreter |
There was a problem hiding this comment.
This is indeed quite difficult to read too...
There was a problem hiding this comment.
Yeah, it's not the end form definitely - I think we will get rid of elastic4s and keep it down to official java client only, but wrap it in monad. Since we have AST already I have a feeling that free monad might be a good fit here (we'd just need to abstract our ADT over some generic param).
Some sketch of it will land in some next PR I think.
| bool.not(in.toList.map(termsQuery(_, value.toList: _*))) | ||
| case (bool, QueryFunction.matches(in, value)) ⇒ | ||
| val fields = in.toList | ||
| bool.must(value.toList.map(q ⇒ multiMatchQuery(q).fields(fields))) |
There was a problem hiding this comment.
Because those are NonEmptyLists, so I need to convert them to plain Scala Lists to send them later either to method that accepts Seq or varargs.
| object listOfAnyValueF extends Poly1 { | ||
| implicit def caseJsonNumber = at[QueryValue[JsonNumber]](_.fold(queryValueF).asInstanceOf[List[AnyRef]]) | ||
| implicit def caseString = at[QueryValue[String]](_.fold(queryValueF).asInstanceOf[List[AnyRef]]) |
There was a problem hiding this comment.
Type annotations for these implicits?
There was a problem hiding this comment.
Yeah, I thought about it but it boils down to the below:implicit def caseString: Case.Aux[QueryValue[String], List[AnyRef]]
Do you think it's helpful to have such signature? Or it's more care about compilation times?
If the latter I wouldn't worry imho, as search service rather should not grow big.
I can add it though, if you prefer.
There was a problem hiding this comment.
Well, I thought more of a saving compiler's cycles here. So prob a good idea.
Also, maybe make listOfAnyValueF implicits into vals ? As they doesn't have any input params.
kjanosz
commented
Jun 19, 2017
Suggestions addressed |
michalrus
commented
Jun 19, 2017
Thank you! |
EDIT:
I've removed support for nested fields from scope of this PR to avoid growing it too big.