Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Term queries #36

Merged
merged 6 commits into from May 14, 2012

Conversation

Projects
None yet
2 participants
Contributor

adamalix commented May 14, 2012

This pull request introduces unanalyzed query types and fields that have the ability to be used as filter queries that are optionally cached in ElasticSearch.

adamalix added some commits May 10, 2012

Initial stab at Term queries and filter caching:
This commit adds the ability to have unanalyzed fields and to also cache filter
queries to speed up queries on Elasticsearch.
TODOs:
- Debug commented out line in testUnanalyzed Unit test (ElasticQueryTest:308)
  `"terms" : { "field" : [ [ "value1, "value2" ] ] } ` queries don't work
  because of a SearchParseException.
- Make SlashemGeoField extend SlashemUnanalyzedStringField
- Decide what to do for Solr queries on this field type (in the case of
  SlashemGeoField).  Do we want two separate field types one for both backends?
  The current plan is to not implement Term queries for Solr because we receive
  no benefit there.
Changed SlashemGeoField to be unanalyzed:
- SlashemGeoField now extends SlashemUnanalyzedStringField
- Fixed extend() for Term[T] queries because of failing unit tests
Added changes from Pull Request 34 feedback:
- Added Solr tests for Terms queries
- Added more comprehensive docstrings
- More comprehensive Elastic Tests
- Fixed Solr Terms queries

@holdenk holdenk commented on an outdated diff May 14, 2012

src/main/scala/com/foursquare/slashem/Ast.scala
+ *
+ * By default, elasticFilter() will always be cached!
+ */
+ case class Term[T](query: Iterable[T], escaped: Boolean = true, cached: Boolean = true) extends Query[T] {
+ // hack for single term queries
+ def this(query: T) = this(List(query))
+ /** @inheritdoc */
+ //def extend() = throw new UnimplementedException("Slashem does not support Term queries Solr")
+ def extend(): String = {
+ escaped match {
+ // hack to fix wrapping the queries in a List()
+ case true => {
+ val queries = query.map(q => {'"' + escape(q.toString) + '"'})
+ queries.mkString(" OR ")
+ }
+// case true => {'"' + query.mkString("\" OR \"")
@holdenk

holdenk May 14, 2012

Contributor

Commented out code

@holdenk holdenk commented on an outdated diff May 14, 2012

src/main/scala/com/foursquare/slashem/Ast.scala
@@ -7,6 +7,7 @@ import org.elasticsearch.index.query.{FilterBuilder => ElasticFilterBuilder,
QueryBuilder => ElasticQueryBuilder,
QueryBuilders => EQueryBuilders,
QueryStringQueryBuilder}
+import scalaj.collection.Imports._
@holdenk

holdenk May 14, 2012

Contributor

killme

holdenk added a commit that referenced this pull request May 14, 2012

@holdenk holdenk merged commit a71fd7d into master May 14, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment