Master  
                (javaSuperMaster)
               
                 
              
                  
                    January 19, 2018, 12:41pm
                   
                   
              1 
               
             
            
              i want to migrate elastic search from 2.x to 6.x.
In this process created new indexed and loaded data from DB to ES 6.x but in service layer(java) facing some issue like below
orQueryBuilder.add(QueryBuilders.termQuery("middleSchoolInd", "true"))
orQueryBuilder is depreciated so can i use code like below
QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("highSchoolInd", "true"));
             
            
               
               
               
            
                
            
           
          
            
              
                dadoonet  
                (David Pilato)
               
              
                  
                    January 19, 2018,  1:01pm
                   
                   
              2 
               
             
            
              Calling should clause is more appropriate IMO.
             
            
               
               
               
            
            
           
          
            
              
                Master  
                (javaSuperMaster)
               
              
                  
                    January 22, 2018,  4:05am
                   
                   
              3 
               
             
            
              so modified my code as
private void addSchoolAgeFilters(BoolQueryBuilder orQueryBuilder, SchoolSearchForm form) { // actual code
//below code is actual code
if (form.isMiddle()) {
       // orQueryBuilder.add(QueryBuilders.termQuery("middleSchoolInd", "true"));
 
//modified code as below, is it right? 
orQueryBuilder.should(QueryBuilders.termQuery("middleSchoolInd", "true")); 
}
             
            
               
               
               
            
            
           
          
            
              
                dadoonet  
                (David Pilato)
               
              
                  
                    January 22, 2018,  4:17am
                   
                   
              4 
               
             
            
              Please format your code using </> icon as explained in this guide . It will make your post more readable.
Or use markdown style like:
```
CODE
```
 
It looks good to me.
             
            
               
               
               
            
            
           
          
            
              
                Master  
                (javaSuperMaster)
               
              
                  
                    January 22, 2018, 11:33am
                   
                   
              5 
               
             
            
              Getting this error "The method add(RangeQueryBuilder) is undefined for the type QueryBuilder"
 private void addLocationFilter(QueryBuilder andQueryBuilder, SchoolSearchForm form) {
          
      	andQueryBuilder.add(QueryBuilders.rangeQuery("location.lat").gte(form.getMinLat()).lte(form.getMaxLat()));
        andQueryBuilder.add(QueryBuilders.rangeQuery("location.lon").gte(form.getMinLng()).lte(form.getMaxLng()));
    } 
             
            
               
               
               
            
            
           
          
            
              
                dadoonet  
                (David Pilato)
               
              
                  
                    January 22, 2018, 11:47am
                   
                   
              6 
               
             
            
              That's true. QueryBuilder does not have a add() method.
It's unclear what kind of result you want to have. But if you have a BoolQueryBuilder, you can use filter(xxx) and add any filter you want (your range query).
BTW this is super weird that you are doing "manual" filtering on lat/lon as we have dedicated geo_point fields and specific queries for them.
             
            
               
               
               
            
            
           
          
            
              
                Master  
                (javaSuperMaster)
               
              
                  
                    January 22, 2018, 12:01pm
                   
                   
              7 
               
             
            
              Commented code is old error code , next to commented code is new code which cleared error, please suggest is it right?
  private void addAllSchoolFilters(QueryBuilder andQuery, SchoolSearchForm form) {
        if (form.hasAgeFilter()) {
        	// OrQueryBuilder orQb = QueryBuilders.orQuery();
        	 BoolQueryBuilder orQb = QueryBuilders.boolQuery();
        	this.addSchoolAgeFilters(orQb, form);
        	
           // andQuery.add(orQb);
            QueryBuilders.boolQuery().filter(orQb);
        }
 private void addLocationFilter(QueryBuilder andQueryBuilder, SchoolSearchForm form) {//andQueryBuilder.add(QueryBuilders.rangeQuery("location.lat").gte(form.getMinLat()).lte(form.getMaxLat()));
        	QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery("location.lat").gte(form.getMinLat()).lte(form.getMaxLat()));
        		
           //andQueryBuilder.add(QueryBuilders.rangeQuery("location.lon").gte(form.getMinLng()).lte(form.getMaxLng()));
        	QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery("location.lon").gte(form.getMinLng()).lte(form.getMaxLng()));
        } 
             
            
               
               
               
            
            
           
          
            
              
                dadoonet  
                (David Pilato)
               
              
                  
                    January 22, 2018,  1:04pm
                   
                   
              8 
               
             
            
              It's unclear to me what you are getting in QueryBuilder andQuery or QueryBuilder andQueryBuilder.
Anyway, you can write something like:
client.search(new SearchRequest()
    .source(new SearchSourceBuilder().query(
            QueryBuilders.boolQuery()
                .filter(QueryBuilders.rangeQuery("location.lat").gte(0).lte(0))
                .filter(QueryBuilders.rangeQuery("location.lon").gte(0).lte(0))
    ))
);
 
             
            
               
               
               
            
                
            
           
          
            
              
                Master  
                (javaSuperMaster)
               
              
                  
                    January 23, 2018,  4:15am
                   
                   
              9 
               
             
            
              QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery("location.lon").gte(form.getMinLng()).lte(form.getMaxLng()));
 
Its works for me, is it right way?
             
            
               
               
               
            
            
           
          
            
              
                Master  
                (javaSuperMaster)
               
              
                  
                    January 23, 2018,  4:29am
                   
                   
              10 
               
             
            
              Is there any url to check for the depreciated/replacement classes and methods to migrate to ES 6.1.0 for java api
             
            
               
               
               
            
            
           
          
            
              
                dadoonet  
                (David Pilato)
               
              
                  
                    January 23, 2018,  7:22am
                   
                   
              11 
               
             
            
              It looks ok. But as I said it's a strange way to query for location points.
BTW this is super weird that you are doing "manual" filtering on lat/lon as we have dedicated geo_point fields and specific queries for them.
 
             
            
               
               
               
            
            
           
          
            
              
                Master  
                (javaSuperMaster)
               
              
                  
                    January 23, 2018,  8:23am
                   
                   
              12 
               
             
            
              Ok Thanks, Please let me know is there any url for check the depreciated/replacement classes and methods to migrate to ES 6.1.0 for java api from ES 2.3.4
             
            
               
               
               
            
            
           
          
            
              
                dadoonet  
                (David Pilato)
               
              
                  
                    January 23, 2018,  8:49am
                   
                   
              13 
               
             
            
              No. Not from 2.x to 6.x. 
But if you are using the 5.6 version, then I think that most of the deprecated methods as marked as @Deprecated.
             
            
               
               
               
            
            
           
          
            
              
                Master  
                (javaSuperMaster)
               
              
                  
                    January 24, 2018,  4:12am
                   
                   
              14 
               
             
            
              Spring doesn't support elasticsearch 6.1.0 right?
We have to use Rest client , customised code written by our self? Base on the below url
             
            
               
               
               
            
            
           
          
            
              
                dadoonet  
                (David Pilato)
               
              
                  
                    January 24, 2018, 10:07am
                   
                   
              15 
               
             
            
              Indeed. I did not update the project for a long time. I just opened
  
  
    
 
 
 
 	update 
   
  
    
    
  
  
 
Note that it might be possible to use the older version by also adding:
        <dependency>
            <groupId>fr.pilato.elasticsearch</groupId>
            <artifactId>elasticsearch-beyonder</artifactId>
            <version>5.1</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-client</artifactId>
            <version>6.1.2</version>
        </dependency>
 
(Not tested though)
             
            
               
               
              1 Like 
            
            
           
          
            
              
                Master  
                (javaSuperMaster)
               
              
                  
                    January 25, 2018, 10:49am
                   
                   
              16 
               
             
            
              getting this error after tried to integrate spring and elastic search
 <dependency>
            <groupId>fr.pilato.elasticsearch</groupId>
            <artifactId>elasticsearch-beyonder</artifactId>
            <version>5.1</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-client</artifactId>
            <version>6.1.2</version>
        </dependency>
         <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-elasticsearch</artifactId>
            <version>3.0.2.RELEASE</version>  </dependency>
            
         <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-elasticsearch</artifactId>
        <version>3.0.3.RELEASE</version>
    </dependency>
    
		<dependency>
			<groupId>fr.pilato.spring</groupId>
			<artifactId>spring-elasticsearch</artifactId>
			<version>2.1.0</version>
		</dependency>
 
Error occured processing XML 
'org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension.getRepositoryFactoryBeanClassName()Ljava/ 
lang/String;'. See Error Log for more details
             
            
               
               
               
            
            
           
          
            
              
                dadoonet  
                (David Pilato)
               
              
                  
                    January 25, 2018, 11:10am
                   
                   
              17 
               
             
            
              Sounds like I did not release 5.0 o_O...
May be use spring-elasticsearch 5.0-SNAPSHOT ?
             
            
               
               
               
            
            
           
          
            
              
                Master  
                (javaSuperMaster)
               
              
                  
                    January 25, 2018, 12:14pm
                   
                   
              18 
               
             
            
              Is there any other way to implement elasticsearch 6.x with spring  ?
             
            
               
               
               
            
            
           
          
            
              
                dadoonet  
                (David Pilato)
               
              
                  
                    January 25, 2018,  1:01pm
                   
                   
              19 
               
             
            
              I don't know if this can help:
You can produce your own bean here with the rest Client I think.
             
            
               
               
               
            
            
           
          
            
              
                system  
                (system)
                  Closed 
               
              
                  
                    February 22, 2018,  1:01pm
                   
                   
              20 
               
             
            
              This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.