Elasticsearch-php: Add ElasticSearch 7 params to old versions

Created on 12 Apr 2019  路  7Comments  路  Source: elastic/elasticsearch-php

Summary of problem or feature request

I am using "elasticsearch/elasticsearch": 5.4.0 to support elasticsearch 5.0 and upper.
Since Elasticsearch 7.0 was released, type shouldn't be used for creating Mappings.
https://www.elastic.co/guide/en/elasticsearch/reference/master/removal-of-types.html

Since elasticsearch/elasticsearch put mapping requires a type for elasticsearch 5:
https://github.com/elastic/elasticsearch-php/blob/v5.4.0/src/Elasticsearch/Endpoints/Indices/Mapping/Put.php#L44
So, we can't drop it.

So it whould be awesome to include the param


in the


Function of the Put.php.
https://github.com/elastic/elasticsearch-php/blob/v5.4.0/src/Elasticsearch/Endpoints/Indices/Mapping/Put.php#L63

and

"rest_total_hits_as_int", "track_total_hits"

to the Search.php.

This whould enable us to be compatible to 5, 6 and 7.

Code snippet of problem

Change

    /**
     * @return string[]
     */
    public function getParamWhitelist()
    {
        return array(
            'ignore_conflicts',
            'timeout',
            'master_timeout',
            'ignore_unavailable',
            'allow_no_indices',
            'expand_wildcards',
            'update_all_types'
        );
    }

to:

    /**
     * @return string[]
     */
    public function getParamWhitelist()
    {
        return array(
            'ignore_conflicts',
            'timeout',
            'master_timeout',
            'ignore_unavailable',
            'allow_no_indices',
            'expand_wildcards',
            'update_all_types',
            'include_type_name'
        );
    }

And

    public function getParamWhitelist()
    {
        return array(
            'analyzer',
            'analyze_wildcard',
            'default_operator',
            'df',
            'explain',
            'from',
            'ignore_unavailable',
            'allow_no_indices',
            'expand_wildcards',
            'indices_boost',
            'lenient',
            'lowercase_expanded_terms',
            'preference',
            'q',
            'query_cache',
            'request_cache',
            'routing',
            'scroll',
            'search_type',
            'size',
            'slice',
            'sort',
            'source',
            '_source',
            '_source_exclude',
            '_source_include',
            'stats',
            'suggest_field',
            'suggest_mode',
            'suggest_size',
            'suggest_text',
            'timeout',
            'version',
            'fielddata_fields',
            'docvalue_fields',
            'filter_path',
            'terminate_after',
            'stored_fields',
            'batched_reduce_size',
            'typed_keys'
        );
    }
    public function getParamWhitelist()
    {
        return array(
            'analyzer',
            'analyze_wildcard',
            'default_operator',
            'df',
            'explain',
            'from',
            'ignore_unavailable',
            'allow_no_indices',
            'expand_wildcards',
            'indices_boost',
            'lenient',
            'lowercase_expanded_terms',
            'preference',
            'q',
            'query_cache',
            'request_cache',
            'routing',
            'scroll',
            'search_type',
            'size',
            'slice',
            'sort',
            'source',
            '_source',
            '_source_exclude',
            '_source_include',
            'stats',
            'suggest_field',
            'suggest_mode',
            'suggest_size',
            'suggest_text',
            'timeout',
            'version',
            'fielddata_fields',
            'docvalue_fields',
            'filter_path',
            'terminate_after',
            'stored_fields',
            'batched_reduce_size',
            'typed_keys',
            'rest_total_hits_as_int', 
            'track_total_hits'
        );
    }

-->

System details

  • Operating System
    Linux/Windows/Max-Os
  • PHP Version
    7.2 or higher
  • ES-PHP client version
    5.4.0
  • Elasticsearch version
    5, 6 at the moment and hopefully 7

All 7 comments

@PascalThesing I'm working to release elasticsearch-php 7.0.0 soon, I'm still fixing some issues for 6.7. Thanks for reporting this!

@PascalThesing I've already added include_type_name for Elasticsearch\Endpoints\Indices\Mapping\Put and rest_total_hits_as_int in Elasticsearch\Endpoints\Search for 6.7.0. I'll add the missing track_total_hits for 7.0.0.

Is there any reason for not adding track_total_hits to 6.7.0?

No reason, I'm considering to add it in 6.7.1.

That would be awesome!

Hey @ezimuel,
any idea when 6.7.1 will be released?

@PascalThesing, @shyim just released 6.7.1: https://github.com/elastic/elasticsearch-php/releases/tag/v6.7.1 with track_total_hits in search endpoint.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thinkspill picture thinkspill  路  3Comments

opeadeyomoye picture opeadeyomoye  路  4Comments

KarboniteKream picture KarboniteKream  路  5Comments

marksparrish picture marksparrish  路  6Comments

amorphine picture amorphine  路  6Comments