<legend id='TRVOO'><style id='TRVOO'><dir id='TRVOO'><q id='TRVOO'></q></dir></style></legend>

<i id='TRVOO'><tr id='TRVOO'><dt id='TRVOO'><q id='TRVOO'><span id='TRVOO'><b id='TRVOO'><form id='TRVOO'><ins id='TRVOO'></ins><ul id='TRVOO'></ul><sub id='TRVOO'></sub></form><legend id='TRVOO'></legend><bdo id='TRVOO'><pre id='TRVOO'><center id='TRVOO'></center></pre></bdo></b><th id='TRVOO'></th></span></q></dt></tr></i><div id='TRVOO'><tfoot id='TRVOO'></tfoot><dl id='TRVOO'><fieldset id='TRVOO'></fieldset></dl></div>
    <bdo id='TRVOO'></bdo><ul id='TRVOO'></ul>

      <small id='TRVOO'></small><noframes id='TRVOO'>

      <tfoot id='TRVOO'></tfoot>

        在 Spring java 框架中使用 ElasticSearch 的最佳方式

        时间:2023-09-25

          <small id='8pwxj'></small><noframes id='8pwxj'>

              <tbody id='8pwxj'></tbody>

            • <bdo id='8pwxj'></bdo><ul id='8pwxj'></ul>
              <tfoot id='8pwxj'></tfoot>

              <i id='8pwxj'><tr id='8pwxj'><dt id='8pwxj'><q id='8pwxj'><span id='8pwxj'><b id='8pwxj'><form id='8pwxj'><ins id='8pwxj'></ins><ul id='8pwxj'></ul><sub id='8pwxj'></sub></form><legend id='8pwxj'></legend><bdo id='8pwxj'><pre id='8pwxj'><center id='8pwxj'></center></pre></bdo></b><th id='8pwxj'></th></span></q></dt></tr></i><div id='8pwxj'><tfoot id='8pwxj'></tfoot><dl id='8pwxj'><fieldset id='8pwxj'></fieldset></dl></div>
              <legend id='8pwxj'><style id='8pwxj'><dir id='8pwxj'><q id='8pwxj'></q></dir></style></legend>
                • 本文介绍了在 Spring java 框架中使用 ElasticSearch 的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在开发一个系统,计划将弹性搜索用作数据存储库.我正在尝试选择开发我的应用程序的最佳方式,该应用程序可以索引和查询来自 elasticsearch 的数据.我的系统是建立在 Spring 框架之上的.

                  I'm developing a system which is planning to use elasticsearch as an data repository. I'm trying to choose the best way to develop my application that can index and query data from elasticsearch. The system I have is built on top of Spring framework.

                  使用Spring-data-elasticsearch(https:///github.com/spring-projects/spring-data-elasticsearch)?

                  或者使用elasticsearch核心库本身是一个不错的选择?

                  Or is it a good choice to use elasticsearch core libraries itself?

                  我需要处理嵌套数据(内部对象),但 Spring-data-elasticsearch 最近似乎没有任何操作.

                  I need to handle nested data (inner object) but Spring-data-elasticsearch seems to have no operations for that recently.

                  我希望我能找到问题的解决方案.提前致谢.

                  I hope I can find a solution for the question. Thanks in advance.

                  推荐答案

                  Spring data elasticsearch支持elasticsearch的大部分常用功能集,包括Nested、Inner Objects和Parent Child(最近).

                  Spring data elasticsearch supports most of the common feature set of elasticsearch including Nested, Inner Objects and Parent Child (recently).

                  当您说要使用嵌套数据(内部对象)时,请清楚elasticsearch有两个概念:内部对象和嵌套对象.

                  When you said that want to use nested data (inner object), please be clear as elasticsearch has two concepts: Inner Object and Nested Object.

                  详细解释可以在在elasticsearch中管理关系找到

                  个人实体:

                  @Document(indexName = "person" , type = "user")
                  
                  public class Person {
                  
                      @Id
                      private String id;
                  
                      private String name;
                  
                      @Field( type = FieldType.Nested)
                      private List<Car> car;
                  
                      // setters-getters
                  }
                  

                  汽车实体:

                  public class Car {
                      private String name;
                      private String model;
                      //setters and getters 
                  }
                  

                  设置数据:

                  Person foo = new Person();
                  foo.setName("Foo");
                  foo.setId("1");
                  
                  List<Car> cars = new ArrayList<Car>();
                  Car subaru = new Car();
                  subaru.setName("Subaru");
                  subaru.setModel("Imprezza");
                  cars.add(subaru);
                  foo.setCar(cars);
                  

                  索引:

                  IndexQuery indexQuery = new IndexQuery();
                  indexQuery.setId(foo.getId());
                  indexQuery.setObject(foo);
                  
                  //creating mapping
                  elasticsearchTemplate.putMapping(Person.class);
                  //indexing document
                  elasticsearchTemplate.index(indexQuery);
                  //refresh
                  elasticsearchTemplate.refresh(Person.class, true);
                  

                  搜索:

                  QueryBuilder builder = nestedQuery("car", boolQuery()
                      .must(termQuery("car.name", "subaru"))
                      .must(termQuery("car.model", "imprezza")));
                  
                  SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(builder).build();
                  List<Person> persons = elasticsearchTemplate.queryForList(searchQuery, Person.class);
                  

                  您可以在 嵌套对象测试

                  这篇关于在 Spring java 框架中使用 ElasticSearch 的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:类似 Django 的 Java 框架 下一篇:Java的全栈框架

                  相关文章

                  <small id='Ci5aF'></small><noframes id='Ci5aF'>

                    1. <tfoot id='Ci5aF'></tfoot>

                    2. <i id='Ci5aF'><tr id='Ci5aF'><dt id='Ci5aF'><q id='Ci5aF'><span id='Ci5aF'><b id='Ci5aF'><form id='Ci5aF'><ins id='Ci5aF'></ins><ul id='Ci5aF'></ul><sub id='Ci5aF'></sub></form><legend id='Ci5aF'></legend><bdo id='Ci5aF'><pre id='Ci5aF'><center id='Ci5aF'></center></pre></bdo></b><th id='Ci5aF'></th></span></q></dt></tr></i><div id='Ci5aF'><tfoot id='Ci5aF'></tfoot><dl id='Ci5aF'><fieldset id='Ci5aF'></fieldset></dl></div>
                      • <bdo id='Ci5aF'></bdo><ul id='Ci5aF'></ul>

                      <legend id='Ci5aF'><style id='Ci5aF'><dir id='Ci5aF'><q id='Ci5aF'></q></dir></style></legend>