Skip to content

Commit

Permalink
preserve the original filters set in the DF config
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranchitturi committed Apr 21, 2016
1 parent 329e1e0 commit 0b40ea0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/scala/com/lucidworks/spark/SolrRelation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class SolrRelation(
conf.flattenMultivalued.getOrElse(true))

val query: SolrQuery = buildQuery
// Preserve the initial filters if any present in arbitrary config
val queryFilters: Array[String] = if (query.getFilterQueries != null) query.getFilterQueries else Array.empty[String]
val querySchema: StructType = {
if (dataFrame.isDefined) {
dataFrame.get.schema
Expand Down Expand Up @@ -123,17 +125,19 @@ class SolrRelation(
}
}

// We set aliasing to retrieve docValues from function queries. This can be removed after Solr version 5.5 is released
// We use aliasing to retrieve docValues (that are indexed and not stored). This can be removed after upgrading to 5.5
if (query.getFields != null && query.getFields.length > 0) {
if (conf.docValues.getOrElse(false)) {
SolrRelationUtil.setAliases(query.getFields.split(","), query, baseSchema)
}
}

// Clear all existing filters
// Clear all existing filters except the original filters set in the config.
if (!filters.isEmpty) {
query.remove("fq")
query.setFilterQueries(queryFilters:_*)
filters.foreach(filter => SolrRelationUtil.applyFilter(filter, query, baseSchema))
} else {
query.setFilterQueries(queryFilters:_*)
}

if (log.isInfoEnabled) {
Expand Down

0 comments on commit 0b40ea0

Please sign in to comment.