Skip to content

Commit

Permalink
Search with parameters in Request Body
Browse files Browse the repository at this point in the history
  • Loading branch information
alegauss committed Nov 7, 2024
1 parent f01fad9 commit 838dcfc
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ public ResponseEntity<TurSNSiteSearchBean> turSNSiteSearchSelectPost(
turSNSearchProcess.requestTargetingRules(turSNSitePostParamsBean.getTargetingRules()));
return new ResponseEntity<>(turSNSearchProcess.search(new TurSNSiteSearchContext(siteName,
new TurSEParameters(q, new TurSEFilterQueryParameters(filterQueriesDefault, filterQueriesAnd,
filterQueriesOr, fqOperator), currentPage, sort, rows, group, autoCorrectionDisabled), locale,
filterQueriesOr, fqOperator), currentPage, sort, rows, group, autoCorrectionDisabled,
turSNSitePostParamsBean), locale,
TurSNUtils.requestToURI(request), turSNSitePostParamsBean)), HttpStatus.OK);
} else {
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.viglet.turing.commons.se;

import com.viglet.turing.commons.sn.bean.TurSNSitePostParamsBean;
import lombok.Getter;
import lombok.Setter;

Expand All @@ -16,7 +17,7 @@ public class TurSEParameters implements Serializable {
private Integer rows;
private String group;
private Integer autoCorrectionDisabled;

private TurSNSitePostParamsBean turSNSitePostParamsBean;
public TurSEParameters(String query, TurSEFilterQueryParameters filterQueries,
Integer currentPage, String sort, Integer rows,
String group, Integer autoCorrectionDisabled) {
Expand All @@ -28,6 +29,49 @@ public TurSEParameters(String query, TurSEFilterQueryParameters filterQueries,
this.rows = rows;
this.group = group;
this.autoCorrectionDisabled = autoCorrectionDisabled;
this.turSNSitePostParamsBean = null;
}
public TurSEParameters(String query, TurSEFilterQueryParameters filterQueries,
Integer currentPage, String sort, Integer rows,
String group, Integer autoCorrectionDisabled, TurSNSitePostParamsBean turSNSitePostParamsBean) {
super();
this.query = query;
this.filterQueries = filterQueries;
this.currentPage = currentPage;
this.sort = sort;
this.rows = rows;
this.group = group;
this.autoCorrectionDisabled = autoCorrectionDisabled;
this.turSNSitePostParamsBean = turSNSitePostParamsBean;
if (turSNSitePostParamsBean != null) {
if (turSNSitePostParamsBean.getSort() != null) {
this.sort = turSNSitePostParamsBean.getSort();
}
if (turSNSitePostParamsBean.getRows() != null) {
this.rows = turSNSitePostParamsBean.getRows();
}
if (turSNSitePostParamsBean.getGroup() != null) {
this.group = turSNSitePostParamsBean.getGroup();
}
if (turSNSitePostParamsBean.getPage() != null) {
this.currentPage = turSNSitePostParamsBean.getPage();
}
if (turSNSitePostParamsBean.getQuery() != null) {
this.query = turSNSitePostParamsBean.getQuery();
}
if (turSNSitePostParamsBean.getFq() != null) {
this.filterQueries.setFq(turSNSitePostParamsBean.getFq());
}
if (turSNSitePostParamsBean.getFqAnd() != null) {
this.filterQueries.setAnd(turSNSitePostParamsBean.getFqAnd());
}
if (turSNSitePostParamsBean.getFqOr() != null) {
this.filterQueries.setOr(turSNSitePostParamsBean.getFqOr());
}
if (turSNSitePostParamsBean.getFqOperator() != null) {
this.filterQueries.setOperator(turSNSitePostParamsBean.getFqOperator());
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.MapSerializer;
import com.viglet.turing.commons.se.TurSEFilterQueryParameters;
import com.viglet.turing.commons.sn.search.TurSNFilterQueryOperator;
import lombok.Getter;
import lombok.Setter;

Expand All @@ -42,8 +44,18 @@
public class TurSNSitePostParamsBean implements Serializable {
private String userId;
private boolean populateMetrics = true;
private String sort;
private String query;
private List<String> fq;
private List<String> fqAnd;
private List<String> fqOr;
private TurSNFilterQueryOperator fqOperator;
private Integer page;
private Integer rows;
private String group;
private String locale;
private boolean disableAutoComplete = false;
private List<String> targetingRules = new ArrayList<>();

@JsonSerialize(keyUsing = MapSerializer.class)
private Map<String, List<String>> targetingRulesWithCondition = new HashMap<>();
@JsonSerialize(keyUsing = MapSerializer.class)
Expand All @@ -56,6 +68,17 @@ public String toString() {
return "TurSNSitePostParamsBean{" +
"userId='" + userId + '\'' +
", populateMetrics=" + populateMetrics +
", sort='" + sort + '\'' +
", query='" + query + '\'' +
", fq=" + fq +
", fqAnd=" + fqAnd +
", fqOr=" + fqOr +
", fqOperator=" + fqOperator +
", page=" + page +
", rows=" + rows +
", group='" + group + '\'' +
", locale='" + locale + '\'' +
", disableAutoComplete=" + disableAutoComplete +
", targetingRules=" + targetingRules +
", targetingRulesWithCondition=" + targetingRulesWithCondition +
", targetingRulesWithConditionAND=" + targetingRulesWithConditionAND +
Expand Down

0 comments on commit 838dcfc

Please sign in to comment.