Skip to content

Commit

Permalink
Merge pull request #448 from SSHOC/bugfix/SSHOC-447_search_bugs
Browse files Browse the repository at this point in the history
[SSHOC-447] Bugs fixed and pom cleared from unnecessary comments.
  • Loading branch information
KlausIllmayer authored Jun 5, 2024
2 parents 55db5c8 + e8148f8 commit 3d7511d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
12 changes: 0 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-solr</artifactId>-->
<!-- <exclusions>-->
<!-- &lt;!&ndash; This is excluded as the version 8.2.0 used by this data solr version-->
<!-- is not able to handle suggester response of solr 9.3 &ndash;&gt;-->
<!-- <exclusion>-->
<!-- <groupId>org.apache.solr</groupId>-->
<!-- <artifactId>solr-solrj</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<!-- This is included to support solr 9.3 -->
<dependency>
<groupId>org.apache.solr</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,26 @@

public class ActorSearchQueryPhrase extends SearchQueryPhrase {
public enum ActorCriteriaParams {
ID(IndexActor.ID_FIELD, 10f),
EXT_ID(IndexActor.EXTERNAL_IDENTIFIER_FIELD, 10f),
NAME(IndexActor.NAME_FIELD, 4f),
EMAIL(IndexActor.EMAIL_FIELD, 4f),
WEBSITE(IndexActor.WEBSITE_FIELD, 4f);
ID(IndexActor.ID_FIELD, 10f, false),
EXT_ID(IndexActor.EXTERNAL_IDENTIFIER_FIELD, 10f, false),
NAME(IndexActor.NAME_FIELD, 4f, true),
EMAIL(IndexActor.EMAIL_FIELD, 4f, true),
WEBSITE(IndexActor.WEBSITE_FIELD, 4f, true);

private final String fieldName;
private final float boost;
private final boolean containsCondition;

ActorCriteriaParams(String fieldName, float boost) {
ActorCriteriaParams(String fieldName, float boost, boolean containsCondition) {
this.fieldName = fieldName;
this.boost = boost;
this.containsCondition = containsCondition;
}

public String getCondition(String expression) {
if (containsCondition) {
return fieldName + COLON + WILDCARD + expression + WILDCARD + CIRCUMFLEX + boost;
}
return fieldName + COLON + expression + CIRCUMFLEX + boost;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public List<QueryPart> parsePhrase(String phrase) {
expression = new StringBuilder();
}
} else if (token.equals("\"")) {
if (expression.length() > 0 && expression.substring(expression.length() - 1, expression.length()).equals("\\")) {
if (expression.length() > 1 && expression.substring(expression.length() - 1, expression.length()).equals("\\")) {
// escaped quote
expression.replace(expression.length() - 1, expression.length(), "\"");
expression.replace(expression.length() - 2, expression.length(), "\"");
} else {
if (insideQuote) {
insideQuote = false;
Expand All @@ -46,7 +46,7 @@ public List<QueryPart> parsePhrase(String phrase) {
}
}
} else {
expression.append(token);
expression.append(ClientUtils.escapeQueryChars(token));
}
}
if (isAcceptableExpression(expression.toString())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,17 @@ public void shouldParseTwoWordPhrase() throws Exception {

assertThat(queryParts, hasSize(2));
assertThat(queryParts, contains(new QueryPart("gephi", false),
new QueryPart("complex+test", false)));
new QueryPart("complex\\+test", false)));
}

@Test
public void canQueryURL() throws Exception {
String phrase = "https://test.eu/test";

List<QueryPart> queryParts = QueryParser.parsePhrase(phrase);

assertThat(queryParts, hasSize(1));
assertThat(queryParts, contains(new QueryPart("https\\:\\/\\/test.eu\\/test", false)));
}

@Test
Expand Down

0 comments on commit 3d7511d

Please sign in to comment.