org.nlpcn.es4sql.query.join.ESNestedLoopsQueryAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch-sql Show documentation
Show all versions of elasticsearch-sql Show documentation
Query elasticsearch using SQL
package org.nlpcn.es4sql.query.join;
import org.elasticsearch.client.Client;
import org.nlpcn.es4sql.domain.Condition;
import org.nlpcn.es4sql.domain.JoinSelect;
import org.nlpcn.es4sql.domain.Where;
import org.nlpcn.es4sql.domain.hints.Hint;
import org.nlpcn.es4sql.domain.hints.HintType;
import org.nlpcn.es4sql.exception.SqlParseException;
import org.nlpcn.es4sql.query.QueryAction;
import org.nlpcn.es4sql.query.SqlElasticRequestBuilder;
import java.util.List;
/**
* Created by Eliran on 15/9/2015.
*/
public class ESNestedLoopsQueryAction extends ESJoinQueryAction {
public ESNestedLoopsQueryAction(Client client, JoinSelect joinSelect) {
super(client, joinSelect);
}
@Override
protected void fillSpecificRequestBuilder(JoinRequestBuilder requestBuilder) throws SqlParseException {
NestedLoopsElasticRequestBuilder nestedBuilder = (NestedLoopsElasticRequestBuilder) requestBuilder;
Where where = joinSelect.getConnectedWhere();
nestedBuilder.setConnectedWhere(where);
}
@Override
protected JoinRequestBuilder createSpecificBuilder() {
return new NestedLoopsElasticRequestBuilder();
}
@Override
protected void updateRequestWithHints(JoinRequestBuilder requestBuilder) {
super.updateRequestWithHints(requestBuilder);
for(Hint hint : this.joinSelect.getHints()){
if(hint.getType() == HintType.NL_MULTISEARCH_SIZE){
Integer multiSearchMaxSize = (Integer) hint.getParams()[0];
((NestedLoopsElasticRequestBuilder) requestBuilder).setMultiSearchMaxSize(multiSearchMaxSize);
}
}
}
private String removeAlias(String field) {
String alias = joinSelect.getFirstTable().getAlias();
if(!field.startsWith(alias+"."))
alias = joinSelect.getSecondTable().getAlias();
return field.replace(alias+".","");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy