You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by to...@apache.org on 2014/04/14 16:22:30 UTC
svn commit: r1587215 - in /jackrabbit/oak/branches/1.0: ./
oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java
Author: tommaso
Date: Mon Apr 14 14:22:29 2014
New Revision: 1587215
URL: http://svn.apache.org/r1587215
Log:
OAK-1728 - backported OAK-1718 to branch 1.0
Modified:
jackrabbit/oak/branches/1.0/ (props changed)
jackrabbit/oak/branches/1.0/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java
Propchange: jackrabbit/oak/branches/1.0/
------------------------------------------------------------------------------
Merged /jackrabbit/oak/trunk:r1586287
Modified: jackrabbit/oak/branches/1.0/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java?rev=1587215&r1=1587214&r2=1587215&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java (original)
+++ jackrabbit/oak/branches/1.0/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java Mon Apr 14 14:22:29 2014
@@ -106,6 +106,16 @@ public class SolrQueryIndex implements F
StringBuilder queryBuilder = new StringBuilder();
+ if (filter.getFullTextConstraint() != null) {
+ queryBuilder.append(getFullTextQuery(filter.getFullTextConstraint()));
+ queryBuilder.append(' ');
+ } else if (filter.getFulltextConditions() != null) {
+ Collection<String> fulltextConditions = filter.getFulltextConditions();
+ for (String fulltextCondition : fulltextConditions) {
+ queryBuilder.append(fulltextCondition).append(" ");
+ }
+ }
+
Collection<Filter.PropertyRestriction> propertyRestrictions = filter.getPropertyRestrictions();
if (propertyRestrictions != null && !propertyRestrictions.isEmpty()) {
for (Filter.PropertyRestriction pr : propertyRestrictions) {
@@ -172,16 +182,21 @@ public class SolrQueryIndex implements F
queryBuilder.append(':');
queryBuilder.append(first);
} else {
- queryBuilder.append(fieldName).append(':');
if (pr.first != null && pr.last != null && pr.first.equals(pr.last)) {
+ queryBuilder.append(fieldName).append(':');
queryBuilder.append(first);
} else if (pr.first == null && pr.last == null) {
- queryBuilder.append('*');
+ if (!queryBuilder.toString().contains(fieldName + ":")) {
+ queryBuilder.append(fieldName).append(':');
+ queryBuilder.append('*');
+ }
} else if ((pr.first != null && pr.last == null) || (pr.last != null && pr.first == null) || (!pr.first.equals(pr.last))) {
// TODO : need to check if this works for all field types (most likely not!)
+ queryBuilder.append(fieldName).append(':');
queryBuilder.append(createRangeQuery(first, last, pr.firstIncluding, pr.lastIncluding));
} else if (pr.isLike) {
// TODO : the current parameter substitution is not expected to work well
+ queryBuilder.append(fieldName).append(':');
queryBuilder.append(partialEscape(String.valueOf(pr.first.getValue(pr.first.getType())).replace('%', '*').replace('_', '?')));
} else {
throw new RuntimeException("[unexpected!] not handled case");
@@ -208,16 +223,6 @@ public class SolrQueryIndex implements F
}
}
- if (filter.getFullTextConstraint() != null) {
- queryBuilder.append(getFullTextQuery(filter.getFullTextConstraint()));
- queryBuilder.append(' ');
- } else if (filter.getFulltextConditions() != null) {
- Collection<String> fulltextConditions = filter.getFulltextConditions();
- for (String fulltextCondition : fulltextConditions) {
- queryBuilder.append(fulltextCondition).append(" ");
- }
- }
-
Filter.PathRestriction pathRestriction = filter.getPathRestriction();
if (pathRestriction != null) {
String path = purgePath(filter);
@@ -226,7 +231,6 @@ public class SolrQueryIndex implements F
queryBuilder.append(fieldName);
queryBuilder.append(':');
queryBuilder.append(path);
- queryBuilder.append(' ');
}
}