Del nested query (#38)

This commit is contained in:
malkoas 2023-11-28 11:36:33 +03:00 committed by GitHub
parent 0c72fda474
commit 226d80b352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,13 +5,14 @@ import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.opensearch.client.opensearch.OpenSearchClient;
import org.opensearch.client.opensearch._types.query_dsl.*;
import org.opensearch.client.opensearch._types.query_dsl.BoolQuery;
import org.opensearch.client.opensearch._types.query_dsl.MultiMatchQuery;
import org.opensearch.client.opensearch._types.query_dsl.Query;
import org.opensearch.client.opensearch._types.query_dsl.TextQueryType;
import org.opensearch.client.opensearch.core.SearchResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import static dev.vality.deanonimus.constant.OpenSearchConstants.*;
@Slf4j
@Component
@RequiredArgsConstructor
@ -44,9 +45,7 @@ public class SearchDaoImpl implements SearchDao {
}
private Query searchContractorFields(String text) {
return new NestedQuery.Builder()
.path(CONTRACTOR_INDEX)
.query(new Query(new MultiMatchQuery.Builder()
return new Query(new MultiMatchQuery.Builder()
.fields("contractors.id",
"contractors.registeredUserEmail",
"contractors.russianLegalEntityRegisteredName",
@ -56,21 +55,17 @@ public class SearchDaoImpl implements SearchDao {
"contractors.internationalLegalEntityTradingName")
.query(text)
.type(TextQueryType.Phrase)
.build()))
.build().query();
.build());
}
private Query searchContractFields(String text) {
return new NestedQuery.Builder()
.path(CONTRACT_INDEX)
.query(new Query(new MultiMatchQuery.Builder()
return new Query(new MultiMatchQuery.Builder()
.fields("contracts.id",
"contracts.legalAgreementId",
"contracts.reportActSignerFullName")
.query(text)
.type(TextQueryType.Phrase)
.build()))
.build().query();
.build());
}
private Query searchPartyFields(String text) {
@ -83,28 +78,22 @@ public class SearchDaoImpl implements SearchDao {
}
private Query searchShopFields(String text) {
return new NestedQuery.Builder()
.path(SHOP_INDEX)
.query(new Query(new MultiMatchQuery.Builder()
return new Query(new MultiMatchQuery.Builder()
.fields("shops.id",
"shops.locationUrl",
"shops.detailsName")
.query(text)
.type(TextQueryType.Phrase)
.build()))
.build().query();
.build());
}
private Query searchWalletFields(String text) {
return new NestedQuery.Builder()
.path(WALLET_INDEX)
.query(new Query(new MultiMatchQuery.Builder()
return new Query(new MultiMatchQuery.Builder()
.fields("wallets.id",
"wallets.name")
.query(text)
.type(TextQueryType.Phrase)
.build()))
.build().query();
.build());
}
}