Skip to content

Commit

Permalink
fixes conflict with lemma search
Browse files Browse the repository at this point in the history
  • Loading branch information
RDBloese committed Sep 7, 2023
1 parent e0ca205 commit 3d03007
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public void setContext(Context context) {

}

public void setTokenID(Collection<Token> tokens) {
System.out.println("tesst");
/* public void setTokens(Collection<Token> tokens) {
if (tokens != null) {
BoolQueryBuilder tokenQuery = boolQuery();
String tokenId = tokens.iterator().next().getId();
Expand All @@ -47,7 +46,8 @@ public void setTokenID(Collection<Token> tokens) {
this.filter(tokenQuery);
}
}
}
} */


public void setTokens(Collection<TokenSearchQueryBuilder> tokenQueries) {
BoolQueryBuilder tokenQuery = boolQuery();
Expand All @@ -58,6 +58,7 @@ public void setTokens(Collection<TokenSearchQueryBuilder> tokenQueries) {
this.filter(tokenQuery);
}


public void setPassport(PassportSpec spec) {
log.info("set sentence search passport specs");
if (spec != null && !spec.isEmpty()) {
Expand All @@ -72,7 +73,7 @@ public void setPassport(PassportSpec spec) {
// TODO
public void setTextIds(Collection<String> textIds) {
if (textIds != null) {
log.info("sentence query: receive {} text999999999999 IDs", textIds.size());
log.info("sentence query: receive {} text IDs", textIds.size());
this.filter(QueryBuilders.termsQuery("context.textId", textIds));
}
}
Expand Down
29 changes: 15 additions & 14 deletions src/main/java/tla/backend/es/query/TokenSearchQueryBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@

public class TokenSearchQueryBuilder extends ESQueryBuilder implements MultiLingQueryBuilder {

@Override
public String nestedPath() {
return "tokens.";
}
@Override
public String nestedPath() {
return "tokens.";
}

public void setLemma(Lemmatization lemma) {
if (lemma != null && !lemma.isEmpty()) {
this.must(
QueryBuilders.termQuery(
String.format("%slemma.id", this.nestedPath()),
lemma.getId()
)
);
}
}
public void setTokenId(String tokenId) {
if (tokenId != null) {
this.must(QueryBuilders.termQuery(String.format("%sid", this.nestedPath()), tokenId));
}
}

public void setLemma(Lemmatization lemma) {
if (lemma != null && !lemma.isEmpty()) {
this.must(QueryBuilders.termQuery(String.format("%slemma.id", this.nestedPath()), lemma.getId()));
}
}

}

0 comments on commit 3d03007

Please sign in to comment.