Как использовать QueryByExampleExecutor с spring-data -asticsearch - PullRequest
0 голосов
/ 11 февраля 2020

Я хочу использовать QueryByExampleExecutor с ElasticsearchRepository, но получаю исключение при создании SpringBootApplication. Я использую Gradle со следующими зависимостями:

springboot 2.2.4.RELEASE
spring-boot-starter-data-elasticsearch

Мой репозиторий:

@Repository
public interface OrdersRepository extends ElasticsearchRepository<Orders, String>,
        QueryByExampleExecutor {
    Page<Orders> findByCustomerFirstNameIgnoreCase(String customerFirstName, Pageable pageable);

    Page<Orders> findByCustomerLastNameIgnoreCase(String customerLastName, Pageable pageable);

    Page<Orders> findByOrderNo(Long orderNo, Pageable pageable);
}

Мой контроллер, в котором я использую метод реализации пример за запросом:

@PostMapping("search/any")
public Iterable<Orders> searchByAnyText
            (@RequestBody Orders orders) {
        final Example<Orders> ordersExample = Example.of(orders);
        return repo.findAll(ordersExample);
    }

Это мой класс Orders:

@JsonIgnoreProperties(ignoreUnknown = true)
@Data
@Document(indexName = "#{@indexName}",
        type = "#{@typeName}")
public class Orders {
    @Id
    private String orderHeaderKey;
    @Version
    private Long createdAt;
    private Long updatedAt;
    private String createuserid;
    private String allAddressesVerified;
    private String modifyuserid;
    private String customerZipCode;
    private String customerFirstName;
    private String orderType;

    @Field(type = FieldType.Object)
    private PersonInfoBillTo personInfoBillTo;

    @Field(type = FieldType.Object)
    private List<OrderDate> orderDates;

    private String minOrderStatus;
    private String multipleStatusesExist;
    private String sourceIPAddress;
    private String hasDeliveryLines;
    private String minOrderStatusDesc;
    private String returnByGiftRecipient;
    private String enterpriseCode;
    private String paymentStatus;
    private String taxExemptionCertificate;
    private String status;
    private String taxPayerId;
    private String hasProductLines;

    @Field(type = FieldType.Object)
    private List<OrderLine> orderLines;

    private String hasServiceLines;
    private String customerEMailID;
    private String notificationType;
    private String sellerOrganizationCode;
    private String createts;
    private String orderName;
    private String billToKey;
    private Long orderNo;
    private String searchCriteria1;
    private String originalTotalAmount;
    private String searchCriteria2;
    private String maxOrderStatus;
    private String draftOrderFlag;
    private String enteredBy;
    private String processPaymentOnReturnOrder;
    private String customerPhoneNo;
    private String hasDerivedChild;
    private String noOfAuthStrikes;
    private String documentType;
    private String purpose;
    private String maxOrderStatusDesc;
    private String customerPONo;
    private String hasPendingChanges;
    private String orderDate;
    private String customerRewardsNo;
    private String entryType;
    private String modifyts;
    private String orderComplete;
    private String customerLastName;
    private String notificationReference;
    private String allocationRuleID;
    private String paymentRuleId;
    private String billToID;
    private String holdFlag;
    private String overallStatus;
}

Я получаю ниже исключения (вставляя части исключения) при запуске приложения:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ordersRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property exists found for type Orders!
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
.
.
.   ... 19 common frames omitted
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property exists found for type Orders!
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:94) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:382) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:358) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:311) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:324) ~[na:1.8.0_221]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:293) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:276) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
...