diff --git a/.ci/run-opensearch.sh b/.ci/run-opensearch.sh index 39ca74c8..6dffb281 100755 --- a/.ci/run-opensearch.sh +++ b/.ci/run-opensearch.sh @@ -30,7 +30,7 @@ environment=($(cat <<-END END )) -if [[ "$SECURE_INTEGRATION" == "false" ]] && [[ "$CLUSTER" == "opensearch" ]]; then +if [[ "$SECURE_INTEGRATION" == "false" ]] && [[ "$CLUSTER" == "opensearch" ]] && [[ "$IS_UNRELEASED" == "false" ]]; then security=($(cat <<-END --env plugins.security.disabled=true END @@ -58,40 +58,45 @@ END local_detach="true" if [[ "$i" == "$((NUMBER_OF_NODES-1))" ]]; then local_detach=$DETACH; fi - echo -e "\033[34;1mINFO: building $CLUSTER container\033[0m" - docker build \ - --file=.ci/$CLUSTER/Dockerfile \ - --build-arg SECURE_INTEGRATION=$SECURE_INTEGRATION \ - --build-arg OPENSEARCH_VERSION=$OPENSEARCH_VERSION \ - --tag=$CLUSTER-secure-$SECURE_INTEGRATION \ - . - - echo -e "\033[34;1mINFO:\033[0m Starting container $node_name \033[0m" set -x healthcmd="curl -vvv -s --fail http://localhost:9200/_cluster/health || exit 1" if [[ "$SECURE_INTEGRATION" == "true" ]]; then healthcmd="curl -vvv -s --insecure -u admin:admin --fail https://localhost:9200/_cluster/health || exit 1" fi - docker run \ - --name "$node_name" \ - --network "$network_name" \ - --env "ES_JAVA_OPTS=-Xms1g -Xmx1g" \ - "${environment[@]}" \ - "${volumes[@]}" \ - "${security[@]}" \ - --publish "$http_port":9200 \ - --ulimit nofile=65536:65536 \ - --ulimit memlock=-1:-1 \ - --detach="$local_detach" \ - --health-cmd="$(echo $healthcmd)" \ - --health-interval=2s \ - --health-retries=20 \ - --health-timeout=2s \ - --rm \ - -d \ - $CLUSTER-secure-$SECURE_INTEGRATION; - + CLUSTER_TAG=$CLUSTER + if [[ "$IS_UNRELEASED" == "false" ]]; then + CLUSTER_TAG=$CLUSTER_TAG-secure-$SECURE_INTEGRATION + echo -e "\033[34;1mINFO: building $CLUSTER container\033[0m" + docker build \ + --file=.ci/$CLUSTER/Dockerfile \ + --build-arg SECURE_INTEGRATION=$SECURE_INTEGRATION \ + --build-arg OPENSEARCH_VERSION=$OPENSEARCH_VERSION \ + --tag=$CLUSTER_TAG \ + . + else + CLUSTER_TAG=$CLUSTER_TAG:test + fi + echo -e "\033[34;1mINFO:\033[0m Starting container $node_name \033[0m" + docker run \ + --name "$node_name" \ + --network "$network_name" \ + --env "ES_JAVA_OPTS=-Xms1g -Xmx1g" \ + "${environment[@]}" \ + "${volumes[@]}" \ + "${security[@]}" \ + --publish "$http_port":9200 \ + --ulimit nofile=65536:65536 \ + --ulimit memlock=-1:-1 \ + --detach="$local_detach" \ + --health-cmd="$(echo $healthcmd)" \ + --health-interval=2s \ + --health-retries=20 \ + --health-timeout=2s \ + --rm \ + -d \ + $CLUSTER_TAG; + set +x if wait_for_container "$opensearch_node_name" "$network_name"; then echo -e "\033[32;1mSUCCESS:\033[0m Running on: $node_url\033[0m" diff --git a/.ci/run-tests b/.ci/run-tests index c9701fb7..171daa7f 100755 --- a/.ci/run-tests +++ b/.ci/run-tests @@ -15,6 +15,12 @@ else export OPENSEARCH_URL_EXTENSION="http" fi +export IS_UNRELEASED=false +if [[ "$OPENSEARCH_VERSION" == *"SNAPSHOT" ]]; then + IS_UNRELEASED=true +fi + +echo -e "\033[1m>>>>> Unreleased is $IS_UNRELEASED >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m" script_path=$(dirname $(realpath -s $0)) source $script_path/functions/imports.sh set -euo pipefail diff --git a/.github/workflows/integration-opendistro.yml b/.github/workflows/integration-opendistro.yml deleted file mode 100644 index 5745fd33..00000000 --- a/.github/workflows/integration-opendistro.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Integration tests with OpenDistro - -on: [push, pull_request] - -jobs: - integration: - name: Integ - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - secured: ["true", "false"] - - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Integ opendistro secured=${{ matrix.secured }} - run: "./.ci/run-tests opendistro ${{ matrix.secured }}" diff --git a/.github/workflows/integration-unreleased.yml b/.github/workflows/integration-unreleased.yml new file mode 100644 index 00000000..88dccd05 --- /dev/null +++ b/.github/workflows/integration-unreleased.yml @@ -0,0 +1,35 @@ +name: Integration with Unreleased OpenSearch + +on: + push: + branches: + - "main" + pull_request: + branches: + - "main" + +env: + OPENSEARCH_VERSION: '2.0' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout OpenSearch + uses: actions/checkout@v2 + with: + repository: opensearch-project/opensearch + ref: ${{ env.OPENSEARCH_VERSION }} + path: opensearch + + # This step builds the docker image tagged as opensearch:test. It will be further used in /ci/run-tests to test against unreleased OpenSearch. + # Reference: https://github.com/opensearch-project/OpenSearch/blob/2.0/distribution/docker/build.gradle#L190 + - name: Assemble OpenSearch + run: | + cd opensearch + ./gradlew assemble + - name: Checkout Python Client + uses: actions/checkout@v2 + + - name: Run Integration Test + run: "./.ci/run-tests opensearch false ${{ env.OPENSEARCH_VERSION }}.0-SNAPSHOT" \ No newline at end of file diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 4b03c4c5..d71e0bd6 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -11,10 +11,13 @@ jobs: matrix: cluster: ["opensearch"] secured: ["true", "false"] - opensearch_version: [1.0.0, 1.0.1, 1.1.0, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.3.0, 1.3.1] + opensearch_version: [] steps: - name: Checkout + if: ${{ matrix.opensearch_version != ''}} uses: actions/checkout@v2 + - name: Integ ${{ matrix.cluster }} secured=${{ matrix.secured }} version=${{matrix.opensearch_version}} + if: ${{ matrix.opensearch_version != ''}} run: "./.ci/run-tests ${{ matrix.cluster }} ${{ matrix.secured }} ${{ matrix.opensearch_version }}" diff --git a/opensearchpy/_async/client/__init__.py b/opensearchpy/_async/client/__init__.py index cf33ae1d..eaefa43d 100644 --- a/opensearchpy/_async/client/__init__.py +++ b/opensearchpy/_async/client/__init__.py @@ -257,7 +257,7 @@ async def info(self, params=None, headers=None): "version_type", "wait_for_active_shards", ) - async def create(self, index, id, body, doc_type=None, params=None, headers=None): + async def create(self, index, id, body, params=None, headers=None): """ Creates a new document in the index. Returns a 409 response when a document with a same ID already exists in the index. @@ -266,7 +266,6 @@ async def create(self, index, id, body, doc_type=None, params=None, headers=None :arg index: The name of the index :arg id: Document ID :arg body: The document - :arg doc_type: The type of the document :arg pipeline: The pipeline id to preprocess incoming documents with :arg refresh: If `true` then refresh the affected shards to make @@ -288,10 +287,7 @@ async def create(self, index, id, body, doc_type=None, params=None, headers=None if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_create", id) - else: - path = _make_path(index, doc_type, id, "_create") + path = _make_path(index, "_create", id) return await self.transport.perform_request( "PUT", path, params=params, headers=headers, body=body @@ -310,16 +306,13 @@ async def create(self, index, id, body, doc_type=None, params=None, headers=None "version_type", "wait_for_active_shards", ) - async def index( - self, index, body, doc_type=None, id=None, params=None, headers=None - ): + async def index(self, index, body, id=None, params=None, headers=None): """ Creates or updates a document in an index. :arg index: The name of the index :arg body: The document - :arg doc_type: The type of the document :arg id: Document ID :arg if_primary_term: only perform the index operation if the last operation that has changed the document has the specified primary @@ -353,8 +346,7 @@ async def index( if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type is None: - doc_type = "_doc" + doc_type = "_doc" return await self.transport.perform_request( "POST" if id in SKIP_IN_PATH else "PUT", @@ -375,7 +367,7 @@ async def index( "timeout", "wait_for_active_shards", ) - async def bulk(self, body, index=None, doc_type=None, params=None, headers=None): + async def bulk(self, body, index=None, params=None, headers=None): """ Allows to perform multiple index/update/delete operations in a single request. @@ -383,8 +375,6 @@ async def bulk(self, body, index=None, doc_type=None, params=None, headers=None) :arg body: The operation definition and data (action-data pairs), separated by newlines :arg index: Default index for items which don't provide one - :arg doc_type: Default document type for items which don't - provide one :arg _source: True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub- request @@ -414,7 +404,7 @@ async def bulk(self, body, index=None, doc_type=None, params=None, headers=None) body = _bulk_body(self.transport.serializer, body) return await self.transport.perform_request( "POST", - _make_path(index, doc_type, "_bulk"), + _make_path(index, "_bulk"), params=params, headers=headers, body=body, @@ -457,9 +447,7 @@ async def clear_scroll(self, body=None, scroll_id=None, params=None, headers=Non "routing", "terminate_after", ) - async def count( - self, body=None, index=None, doc_type=None, params=None, headers=None - ): + async def count(self, body=None, index=None, params=None, headers=None): """ Returns number of documents matching a query. @@ -468,8 +456,6 @@ async def count( Query DSL (optional) :arg index: A comma-separated list of indices to restrict the results - :arg doc_type: A comma-separated list of types to restrict the - results :arg allow_no_indices: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -500,7 +486,7 @@ async def count( """ return await self.transport.perform_request( "POST", - _make_path(index, doc_type, "_count"), + _make_path(index, "_count"), params=params, headers=headers, body=body, @@ -516,14 +502,13 @@ async def count( "version_type", "wait_for_active_shards", ) - async def delete(self, index, id, doc_type=None, params=None, headers=None): + async def delete(self, index, id, params=None, headers=None): """ Removes a document from the index. :arg index: The name of the index :arg id: The document ID - :arg doc_type: The type of the document :arg if_primary_term: only perform the delete operation if the last operation that has changed the document has the specified primary term @@ -549,8 +534,7 @@ async def delete(self, index, id, doc_type=None, params=None, headers=None): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + doc_type = "_doc" return await self.transport.perform_request( "DELETE", _make_path(index, doc_type, id), params=params, headers=headers @@ -591,9 +575,7 @@ async def delete(self, index, id, doc_type=None, params=None, headers=None): "wait_for_active_shards", "wait_for_completion", ) - async def delete_by_query( - self, index, body, doc_type=None, params=None, headers=None - ): + async def delete_by_query(self, index, body, params=None, headers=None): """ Deletes documents matching the provided query. @@ -601,8 +583,6 @@ async def delete_by_query( :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices :arg body: The search definition using the Query DSL - :arg doc_type: A comma-separated list of document types to - search; leave empty to perform the operation on all types :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -681,7 +661,7 @@ async def delete_by_query( return await self.transport.perform_request( "POST", - _make_path(index, doc_type, "_delete_by_query"), + _make_path(index, "_delete_by_query"), params=params, headers=headers, body=body, @@ -737,15 +717,13 @@ async def delete_script(self, id, params=None, headers=None): "version", "version_type", ) - async def exists(self, index, id, doc_type=None, params=None, headers=None): + async def exists(self, index, id, params=None, headers=None): """ Returns information about whether a document exists in an index. :arg index: The name of the index :arg id: The document ID - :arg doc_type: The type of the document (use `_all` to fetch the - first document matching the ID across all types) :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -769,8 +747,7 @@ async def exists(self, index, id, doc_type=None, params=None, headers=None): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + doc_type = "_doc" return await self.transport.perform_request( "HEAD", _make_path(index, doc_type, id), params=params, headers=headers @@ -787,15 +764,13 @@ async def exists(self, index, id, doc_type=None, params=None, headers=None): "version", "version_type", ) - async def exists_source(self, index, id, doc_type=None, params=None, headers=None): + async def exists_source(self, index, id, params=None, headers=None): """ Returns information about whether a document source exists in an index. :arg index: The name of the index :arg id: The document ID - :arg doc_type: The type of the document; deprecated and optional - starting with 7.0 :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -817,10 +792,7 @@ async def exists_source(self, index, id, doc_type=None, params=None, headers=Non if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_source", id) - else: - path = _make_path(index, doc_type, id, "_source") + path = _make_path(index, "_source", id) return await self.transport.perform_request( "HEAD", path, params=params, headers=headers @@ -840,9 +812,7 @@ async def exists_source(self, index, id, doc_type=None, params=None, headers=Non "routing", "stored_fields", ) - async def explain( - self, index, id, body=None, doc_type=None, params=None, headers=None - ): + async def explain(self, index, id, body=None, params=None, headers=None): """ Returns information about why a specific matches (or doesn't match) a query. @@ -850,7 +820,6 @@ async def explain( :arg index: The name of the index :arg id: The document ID :arg body: The query definition using the Query DSL - :arg doc_type: The type of the document :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -877,10 +846,7 @@ async def explain( if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_explain", id) - else: - path = _make_path(index, doc_type, id, "_explain") + path = _make_path(index, "_explain", id) return await self.transport.perform_request( "POST", path, params=params, headers=headers, body=body @@ -934,15 +900,13 @@ async def field_caps(self, body=None, index=None, params=None, headers=None): "version", "version_type", ) - async def get(self, index, id, doc_type=None, params=None, headers=None): + async def get(self, index, id, params=None, headers=None): """ Returns a document. :arg index: The name of the index :arg id: The document ID - :arg doc_type: The type of the document (use `_all` to fetch the - first document matching the ID across all types) :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -966,8 +930,7 @@ async def get(self, index, id, doc_type=None, params=None, headers=None): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + doc_type = "_doc" return await self.transport.perform_request( "GET", _make_path(index, doc_type, id), params=params, headers=headers @@ -1000,15 +963,13 @@ async def get_script(self, id, params=None, headers=None): "version", "version_type", ) - async def get_source(self, index, id, doc_type=None, params=None, headers=None): + async def get_source(self, index, id, params=None, headers=None): """ Returns the source of a document. :arg index: The name of the index :arg id: The document ID - :arg doc_type: The type of the document; deprecated and optional - starting with 7.0 :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -1030,10 +991,7 @@ async def get_source(self, index, id, doc_type=None, params=None, headers=None): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_source", id) - else: - path = _make_path(index, doc_type, id, "_source") + path = _make_path(index, "_source", id) return await self.transport.perform_request( "GET", path, params=params, headers=headers @@ -1049,7 +1007,7 @@ async def get_source(self, index, id, doc_type=None, params=None, headers=None): "routing", "stored_fields", ) - async def mget(self, body, index=None, doc_type=None, params=None, headers=None): + async def mget(self, body, index=None, params=None, headers=None): """ Allows to get multiple documents in one request. @@ -1058,7 +1016,6 @@ async def mget(self, body, index=None, doc_type=None, params=None, headers=None) (containing full document information) or `ids` (when index and type is provided in the URL. :arg index: The name of the index - :arg doc_type: The type of the document :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -1080,7 +1037,7 @@ async def mget(self, body, index=None, doc_type=None, params=None, headers=None) return await self.transport.perform_request( "POST", - _make_path(index, doc_type, "_mget"), + _make_path(index, "_mget"), params=params, headers=headers, body=body, @@ -1095,7 +1052,7 @@ async def mget(self, body, index=None, doc_type=None, params=None, headers=None) "search_type", "typed_keys", ) - async def msearch(self, body, index=None, doc_type=None, params=None, headers=None): + async def msearch(self, body, index=None, params=None, headers=None): """ Allows to execute several search operations in one request. @@ -1104,8 +1061,6 @@ async def msearch(self, body, index=None, doc_type=None, params=None, headers=No definition pairs), separated by newlines :arg index: A comma-separated list of index names to use as default - :arg doc_type: A comma-separated list of document types to use - as default :arg ccs_minimize_roundtrips: Indicates whether network round- trips should be minimized as part of cross-cluster search requests execution Default: true @@ -1135,7 +1090,7 @@ async def msearch(self, body, index=None, doc_type=None, params=None, headers=No body = _bulk_body(self.transport.serializer, body) return await self.transport.perform_request( "POST", - _make_path(index, doc_type, "_msearch"), + _make_path(index, "_msearch"), params=params, headers=headers, body=body, @@ -1148,9 +1103,7 @@ async def msearch(self, body, index=None, doc_type=None, params=None, headers=No "search_type", "typed_keys", ) - async def msearch_template( - self, body, index=None, doc_type=None, params=None, headers=None - ): + async def msearch_template(self, body, index=None, params=None, headers=None): """ Allows to execute several search template operations in one request. @@ -1159,8 +1112,6 @@ async def msearch_template( definition pairs), separated by newlines :arg index: A comma-separated list of index names to use as default - :arg doc_type: A comma-separated list of document types to use - as default :arg ccs_minimize_roundtrips: Indicates whether network round- trips should be minimized as part of cross-cluster search requests execution Default: true @@ -1179,7 +1130,7 @@ async def msearch_template( body = _bulk_body(self.transport.serializer, body) return await self.transport.perform_request( "POST", - _make_path(index, doc_type, "_msearch", "template"), + _make_path(index, "_msearch", "template"), params=params, headers=headers, body=body, @@ -1199,9 +1150,7 @@ async def msearch_template( "version", "version_type", ) - async def mtermvectors( - self, body=None, index=None, doc_type=None, params=None, headers=None - ): + async def mtermvectors(self, body=None, index=None, params=None, headers=None): """ Returns multiple termvectors in one request. @@ -1210,7 +1159,6 @@ async def mtermvectors( parameters per document here. You must at least provide a list of document ids. See documentation. :arg index: The index in which the document resides. - :arg doc_type: The type of the document. :arg field_statistics: Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified @@ -1243,10 +1191,7 @@ async def mtermvectors( :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_mtermvectors") - else: - path = _make_path(index, doc_type, "_mtermvectors") + path = _make_path(index, "_mtermvectors") return await self.transport.perform_request( "POST", path, params=params, headers=headers, body=body @@ -1492,9 +1437,7 @@ async def scroll(self, body=None, scroll_id=None, params=None, headers=None): "typed_keys", "version", ) - async def search( - self, body=None, index=None, doc_type=None, params=None, headers=None - ): + async def search(self, body=None, index=None, params=None, headers=None): """ Returns results matching a query. @@ -1502,8 +1445,6 @@ async def search( :arg body: The search definition using the Query DSL :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - :arg doc_type: A comma-separated list of document types to - search; leave empty to perform the operation on all types :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -1604,7 +1545,7 @@ async def search( return await self.transport.perform_request( "POST", - _make_path(index, doc_type, "_search"), + _make_path(index, "_search"), params=params, headers=headers, body=body, @@ -1659,9 +1600,7 @@ async def search_shards(self, index=None, params=None, headers=None): "search_type", "typed_keys", ) - async def search_template( - self, body, index=None, doc_type=None, params=None, headers=None - ): + async def search_template(self, body, index=None, params=None, headers=None): """ Allows to use the Mustache language to pre-render a search definition. @@ -1669,8 +1608,6 @@ async def search_template( :arg body: The search definition template and its params :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - :arg doc_type: A comma-separated list of document types to - search; leave empty to perform the operation on all types :arg allow_no_indices: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -1704,7 +1641,7 @@ async def search_template( return await self.transport.perform_request( "POST", - _make_path(index, doc_type, "_search", "template"), + _make_path(index, "_search", "template"), params=params, headers=headers, body=body, @@ -1723,9 +1660,7 @@ async def search_template( "version", "version_type", ) - async def termvectors( - self, index, body=None, doc_type=None, id=None, params=None, headers=None - ): + async def termvectors(self, index, body=None, id=None, params=None, headers=None): """ Returns information and statistics about terms in the fields of a particular document. @@ -1734,7 +1669,6 @@ async def termvectors( :arg index: The index in which the document resides. :arg body: Define parameters and or supply a document to get termvectors for. See documentation. - :arg doc_type: The type of the document. :arg id: The id of the document, when not specified a doc param should be supplied. :arg field_statistics: Specifies if document count, sum of @@ -1761,10 +1695,7 @@ async def termvectors( if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_termvectors", id) - else: - path = _make_path(index, doc_type, id, "_termvectors") + path = _make_path(index, "_termvectors", id) return await self.transport.perform_request( "POST", path, params=params, headers=headers, body=body @@ -1784,7 +1715,7 @@ async def termvectors( "timeout", "wait_for_active_shards", ) - async def update(self, index, id, body, doc_type=None, params=None, headers=None): + async def update(self, index, id, body, params=None, headers=None): """ Updates a document with a script or partial document. @@ -1793,7 +1724,6 @@ async def update(self, index, id, body, doc_type=None, params=None, headers=None :arg id: Document ID :arg body: The request definition requires either `script` or partial `doc` - :arg doc_type: The type of the document :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -1827,10 +1757,7 @@ async def update(self, index, id, body, doc_type=None, params=None, headers=None if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_update", id) - else: - path = _make_path(index, doc_type, id, "_update") + path = _make_path(index, "_update", id) return await self.transport.perform_request( "POST", path, params=params, headers=headers, body=body @@ -1873,9 +1800,7 @@ async def update(self, index, id, body, doc_type=None, params=None, headers=None "wait_for_active_shards", "wait_for_completion", ) - async def update_by_query( - self, index, body=None, doc_type=None, params=None, headers=None - ): + async def update_by_query(self, index, body=None, params=None, headers=None): """ Performs an update on every document in the index without changing the source, for example to pick up a mapping change. @@ -1884,8 +1809,6 @@ async def update_by_query( :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices :arg body: The search definition using the Query DSL - :arg doc_type: A comma-separated list of document types to - search; leave empty to perform the operation on all types :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -1967,7 +1890,7 @@ async def update_by_query( return await self.transport.perform_request( "POST", - _make_path(index, doc_type, "_update_by_query"), + _make_path(index, "_update_by_query"), params=params, headers=headers, body=body, diff --git a/opensearchpy/_async/client/__init__.pyi b/opensearchpy/_async/client/__init__.pyi index 81fbd6a6..cc423451 100644 --- a/opensearchpy/_async/client/__init__.pyi +++ b/opensearchpy/_async/client/__init__.pyi @@ -105,7 +105,6 @@ class AsyncOpenSearch(object): id: Any, *, body: Any, - doc_type: Optional[Any] = ..., pipeline: Optional[Any] = ..., refresh: Optional[Any] = ..., routing: Optional[Any] = ..., @@ -131,7 +130,6 @@ class AsyncOpenSearch(object): index: Any, *, body: Any, - doc_type: Optional[Any] = ..., id: Optional[Any] = ..., if_primary_term: Optional[Any] = ..., if_seq_no: Optional[Any] = ..., @@ -162,7 +160,6 @@ class AsyncOpenSearch(object): *, body: Any, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -208,7 +205,6 @@ class AsyncOpenSearch(object): *, body: Optional[Any] = ..., index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., allow_no_indices: Optional[Any] = ..., analyze_wildcard: Optional[Any] = ..., analyzer: Optional[Any] = ..., @@ -241,7 +237,6 @@ class AsyncOpenSearch(object): index: Any, id: Any, *, - doc_type: Optional[Any] = ..., if_primary_term: Optional[Any] = ..., if_seq_no: Optional[Any] = ..., refresh: Optional[Any] = ..., @@ -268,7 +263,6 @@ class AsyncOpenSearch(object): index: Any, *, body: Any, - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -357,7 +351,6 @@ class AsyncOpenSearch(object): index: Any, id: Any, *, - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -386,7 +379,6 @@ class AsyncOpenSearch(object): index: Any, id: Any, *, - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -415,7 +407,6 @@ class AsyncOpenSearch(object): id: Any, *, body: Optional[Any] = ..., - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -469,7 +460,6 @@ class AsyncOpenSearch(object): index: Any, id: Any, *, - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -516,7 +506,6 @@ class AsyncOpenSearch(object): index: Any, id: Any, *, - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -544,7 +533,6 @@ class AsyncOpenSearch(object): *, body: Any, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -571,7 +559,6 @@ class AsyncOpenSearch(object): *, body: Any, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., ccs_minimize_roundtrips: Optional[Any] = ..., max_concurrent_searches: Optional[Any] = ..., max_concurrent_shard_requests: Optional[Any] = ..., @@ -597,7 +584,6 @@ class AsyncOpenSearch(object): *, body: Any, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., ccs_minimize_roundtrips: Optional[Any] = ..., max_concurrent_searches: Optional[Any] = ..., rest_total_hits_as_int: Optional[Any] = ..., @@ -621,7 +607,6 @@ class AsyncOpenSearch(object): *, body: Optional[Any] = ..., index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., field_statistics: Optional[Any] = ..., fields: Optional[Any] = ..., ids: Optional[Any] = ..., @@ -793,7 +778,6 @@ class AsyncOpenSearch(object): *, body: Optional[Any] = ..., index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -878,7 +862,6 @@ class AsyncOpenSearch(object): *, body: Any, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., allow_no_indices: Optional[Any] = ..., ccs_minimize_roundtrips: Optional[Any] = ..., expand_wildcards: Optional[Any] = ..., @@ -910,7 +893,6 @@ class AsyncOpenSearch(object): index: Any, *, body: Optional[Any] = ..., - doc_type: Optional[Any] = ..., id: Optional[Any] = ..., field_statistics: Optional[Any] = ..., fields: Optional[Any] = ..., @@ -942,7 +924,6 @@ class AsyncOpenSearch(object): id: Any, *, body: Any, - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -973,7 +954,6 @@ class AsyncOpenSearch(object): index: Any, *, body: Optional[Any] = ..., - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., diff --git a/opensearchpy/_async/client/indices.py b/opensearchpy/_async/client/indices.py index 6a1f5467..be73065e 100644 --- a/opensearchpy/_async/client/indices.py +++ b/opensearchpy/_async/client/indices.py @@ -332,38 +332,6 @@ async def exists(self, index, params=None, headers=None): "HEAD", _make_path(index), params=params, headers=headers ) - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local") - async def exists_type(self, index, doc_type, params=None, headers=None): - """ - Returns information about whether a particular document type exists. - (DEPRECATED) - - - :arg index: A comma-separated list of index names; use `_all` to - check the types across all indices - :arg doc_type: A comma-separated list of document types to check - :arg allow_no_indices: Whether to ignore if a wildcard indices - expression resolves into no concrete indices. (This includes `_all` - string or when no indices have been specified) - :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg local: Return local information, do not retrieve the state - from master node (default: false) - """ - for param in (index, doc_type): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await self.transport.perform_request( - "HEAD", - _make_path(index, "_mapping", doc_type), - params=params, - headers=headers, - ) - @query_params( "allow_no_indices", "expand_wildcards", @@ -373,9 +341,7 @@ async def exists_type(self, index, doc_type, params=None, headers=None): "timeout", "write_index_only", ) - async def put_mapping( - self, body, index=None, doc_type=None, params=None, headers=None - ): + async def put_mapping(self, body, index=None, params=None, headers=None): """ Updates the index mappings. @@ -384,7 +350,6 @@ async def put_mapping( :arg index: A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. - :arg doc_type: The name of the document type :arg allow_no_indices: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -403,12 +368,9 @@ async def put_mapping( if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - if doc_type not in SKIP_IN_PATH and index in SKIP_IN_PATH: - index = "_all" - return await self.transport.perform_request( "PUT", - _make_path(index, doc_type, "_mapping"), + _make_path(index, "_mapping"), params=params, headers=headers, body=body, @@ -422,13 +384,12 @@ async def put_mapping( "local", "master_timeout", ) - async def get_mapping(self, index=None, doc_type=None, params=None, headers=None): + async def get_mapping(self, index=None, params=None, headers=None): """ Returns mappings for one or more indices. :arg index: A comma-separated list of index names - :arg doc_type: A comma-separated list of document types :arg allow_no_indices: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -445,7 +406,7 @@ async def get_mapping(self, index=None, doc_type=None, params=None, headers=None """ return await self.transport.perform_request( "GET", - _make_path(index, "_mapping", doc_type), + _make_path(index, "_mapping"), params=params, headers=headers, ) @@ -458,16 +419,13 @@ async def get_mapping(self, index=None, doc_type=None, params=None, headers=None "include_type_name", "local", ) - async def get_field_mapping( - self, fields, index=None, doc_type=None, params=None, headers=None - ): + async def get_field_mapping(self, fields, index=None, params=None, headers=None): """ Returns mapping for one or more fields. :arg fields: A comma-separated list of fields :arg index: A comma-separated list of index names - :arg doc_type: A comma-separated list of document types :arg allow_no_indices: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -488,7 +446,7 @@ async def get_field_mapping( return await self.transport.perform_request( "GET", - _make_path(index, "_mapping", doc_type, "field", fields), + _make_path(index, "_mapping", "field", fields), params=params, headers=headers, ) @@ -867,9 +825,7 @@ async def segments(self, index=None, params=None, headers=None): "q", "rewrite", ) - async def validate_query( - self, body=None, index=None, doc_type=None, params=None, headers=None - ): + async def validate_query(self, body=None, index=None, params=None, headers=None): """ Allows a user to validate a potentially expensive query without executing it. @@ -878,9 +834,6 @@ async def validate_query( :arg index: A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices - :arg doc_type: A comma-separated list of document types to - restrict the operation; leave empty to perform the operation on all - types :arg all_shards: Execute validation on all shards instead of one random shard per index :arg allow_no_indices: Whether to ignore if a wildcard indices @@ -907,7 +860,7 @@ async def validate_query( """ return await self.transport.perform_request( "POST", - _make_path(index, doc_type, "_validate", "query"), + _make_path(index, "_validate", "query"), params=params, headers=headers, body=body, @@ -1016,31 +969,6 @@ async def get_upgrade(self, index=None, params=None, headers=None): "GET", _make_path(index, "_upgrade"), params=params, headers=headers ) - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") - async def flush_synced(self, index=None, params=None, headers=None): - """ - Performs a synced flush operation on one or more indices. Synced flush is - deprecated. Use flush instead - - - :arg index: A comma-separated list of index names; use `_all` or - empty string for all indices - :arg allow_no_indices: Whether to ignore if a wildcard indices - expression resolves into no concrete indices. (This includes `_all` - string or when no indices have been specified) - :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, none, all Default: open - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - """ - return await self.transport.perform_request( - "POST", - _make_path(index, "_flush", "synced"), - params=params, - headers=headers, - ) - @query_params( "allow_no_indices", "expand_wildcards", "ignore_unavailable", "status" ) diff --git a/opensearchpy/_async/client/indices.pyi b/opensearchpy/_async/client/indices.pyi index 57eb57fa..b455895d 100644 --- a/opensearchpy/_async/client/indices.pyi +++ b/opensearchpy/_async/client/indices.pyi @@ -249,34 +249,11 @@ class IndicesClient(NamespacedClient): params: Optional[MutableMapping[str, Any]] = ..., headers: Optional[MutableMapping[str, str]] = ..., ) -> bool: ... - async def exists_type( - self, - index: Any, - doc_type: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> bool: ... async def put_mapping( self, *, body: Any, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., allow_no_indices: Optional[Any] = ..., expand_wildcards: Optional[Any] = ..., ignore_unavailable: Optional[Any] = ..., @@ -301,7 +278,6 @@ class IndicesClient(NamespacedClient): self, *, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., allow_no_indices: Optional[Any] = ..., expand_wildcards: Optional[Any] = ..., ignore_unavailable: Optional[Any] = ..., @@ -326,7 +302,6 @@ class IndicesClient(NamespacedClient): fields: Any, *, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., allow_no_indices: Optional[Any] = ..., expand_wildcards: Optional[Any] = ..., ignore_unavailable: Optional[Any] = ..., @@ -636,7 +611,6 @@ class IndicesClient(NamespacedClient): *, body: Optional[Any] = ..., index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., all_shards: Optional[Any] = ..., allow_no_indices: Optional[Any] = ..., analyze_wildcard: Optional[Any] = ..., diff --git a/opensearchpy/client/__init__.py b/opensearchpy/client/__init__.py index 3ff2d73d..96f8d449 100644 --- a/opensearchpy/client/__init__.py +++ b/opensearchpy/client/__init__.py @@ -257,7 +257,7 @@ def info(self, params=None, headers=None): "version_type", "wait_for_active_shards", ) - def create(self, index, id, body, doc_type=None, params=None, headers=None): + def create(self, index, id, body, params=None, headers=None): """ Creates a new document in the index. Returns a 409 response when a document with a same ID already exists in the index. @@ -266,7 +266,6 @@ def create(self, index, id, body, doc_type=None, params=None, headers=None): :arg index: The name of the index :arg id: Document ID :arg body: The document - :arg doc_type: The type of the document :arg pipeline: The pipeline id to preprocess incoming documents with :arg refresh: If `true` then refresh the affected shards to make @@ -288,10 +287,7 @@ def create(self, index, id, body, doc_type=None, params=None, headers=None): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_create", id) - else: - path = _make_path(index, doc_type, id, "_create") + path = _make_path(index, "_create", id) return self.transport.perform_request( "PUT", path, params=params, headers=headers, body=body @@ -310,14 +306,13 @@ def create(self, index, id, body, doc_type=None, params=None, headers=None): "version_type", "wait_for_active_shards", ) - def index(self, index, body, doc_type=None, id=None, params=None, headers=None): + def index(self, index, body, id=None, params=None, headers=None): """ Creates or updates a document in an index. :arg index: The name of the index :arg body: The document - :arg doc_type: The type of the document :arg id: Document ID :arg if_primary_term: only perform the index operation if the last operation that has changed the document has the specified primary @@ -351,8 +346,7 @@ def index(self, index, body, doc_type=None, id=None, params=None, headers=None): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type is None: - doc_type = "_doc" + doc_type = "_doc" return self.transport.perform_request( "POST" if id in SKIP_IN_PATH else "PUT", @@ -373,7 +367,7 @@ def index(self, index, body, doc_type=None, id=None, params=None, headers=None): "timeout", "wait_for_active_shards", ) - def bulk(self, body, index=None, doc_type=None, params=None, headers=None): + def bulk(self, body, index=None, params=None, headers=None): """ Allows to perform multiple index/update/delete operations in a single request. @@ -381,8 +375,6 @@ def bulk(self, body, index=None, doc_type=None, params=None, headers=None): :arg body: The operation definition and data (action-data pairs), separated by newlines :arg index: Default index for items which don't provide one - :arg doc_type: Default document type for items which don't - provide one :arg _source: True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub- request @@ -412,7 +404,7 @@ def bulk(self, body, index=None, doc_type=None, params=None, headers=None): body = _bulk_body(self.transport.serializer, body) return self.transport.perform_request( "POST", - _make_path(index, doc_type, "_bulk"), + _make_path(index, "_bulk"), params=params, headers=headers, body=body, @@ -455,7 +447,7 @@ def clear_scroll(self, body=None, scroll_id=None, params=None, headers=None): "routing", "terminate_after", ) - def count(self, body=None, index=None, doc_type=None, params=None, headers=None): + def count(self, body=None, index=None, params=None, headers=None): """ Returns number of documents matching a query. @@ -464,8 +456,6 @@ def count(self, body=None, index=None, doc_type=None, params=None, headers=None) Query DSL (optional) :arg index: A comma-separated list of indices to restrict the results - :arg doc_type: A comma-separated list of types to restrict the - results :arg allow_no_indices: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -496,7 +486,7 @@ def count(self, body=None, index=None, doc_type=None, params=None, headers=None) """ return self.transport.perform_request( "POST", - _make_path(index, doc_type, "_count"), + _make_path(index, "_count"), params=params, headers=headers, body=body, @@ -512,14 +502,13 @@ def count(self, body=None, index=None, doc_type=None, params=None, headers=None) "version_type", "wait_for_active_shards", ) - def delete(self, index, id, doc_type=None, params=None, headers=None): + def delete(self, index, id, params=None, headers=None): """ Removes a document from the index. :arg index: The name of the index :arg id: The document ID - :arg doc_type: The type of the document :arg if_primary_term: only perform the delete operation if the last operation that has changed the document has the specified primary term @@ -545,8 +534,7 @@ def delete(self, index, id, doc_type=None, params=None, headers=None): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + doc_type = "_doc" return self.transport.perform_request( "DELETE", _make_path(index, doc_type, id), params=params, headers=headers @@ -587,7 +575,7 @@ def delete(self, index, id, doc_type=None, params=None, headers=None): "wait_for_active_shards", "wait_for_completion", ) - def delete_by_query(self, index, body, doc_type=None, params=None, headers=None): + def delete_by_query(self, index, body, params=None, headers=None): """ Deletes documents matching the provided query. @@ -595,8 +583,6 @@ def delete_by_query(self, index, body, doc_type=None, params=None, headers=None) :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices :arg body: The search definition using the Query DSL - :arg doc_type: A comma-separated list of document types to - search; leave empty to perform the operation on all types :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -675,7 +661,7 @@ def delete_by_query(self, index, body, doc_type=None, params=None, headers=None) return self.transport.perform_request( "POST", - _make_path(index, doc_type, "_delete_by_query"), + _make_path(index, "_delete_by_query"), params=params, headers=headers, body=body, @@ -731,15 +717,13 @@ def delete_script(self, id, params=None, headers=None): "version", "version_type", ) - def exists(self, index, id, doc_type=None, params=None, headers=None): + def exists(self, index, id, params=None, headers=None): """ Returns information about whether a document exists in an index. :arg index: The name of the index :arg id: The document ID - :arg doc_type: The type of the document (use `_all` to fetch the - first document matching the ID across all types) :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -763,8 +747,7 @@ def exists(self, index, id, doc_type=None, params=None, headers=None): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + doc_type = "_doc" return self.transport.perform_request( "HEAD", _make_path(index, doc_type, id), params=params, headers=headers @@ -781,15 +764,13 @@ def exists(self, index, id, doc_type=None, params=None, headers=None): "version", "version_type", ) - def exists_source(self, index, id, doc_type=None, params=None, headers=None): + def exists_source(self, index, id, params=None, headers=None): """ Returns information about whether a document source exists in an index. :arg index: The name of the index :arg id: The document ID - :arg doc_type: The type of the document; deprecated and optional - starting with 7.0 :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -811,10 +792,7 @@ def exists_source(self, index, id, doc_type=None, params=None, headers=None): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_source", id) - else: - path = _make_path(index, doc_type, id, "_source") + path = _make_path(index, "_source", id) return self.transport.perform_request( "HEAD", path, params=params, headers=headers @@ -834,7 +812,7 @@ def exists_source(self, index, id, doc_type=None, params=None, headers=None): "routing", "stored_fields", ) - def explain(self, index, id, body=None, doc_type=None, params=None, headers=None): + def explain(self, index, id, body=None, params=None, headers=None): """ Returns information about why a specific matches (or doesn't match) a query. @@ -842,7 +820,6 @@ def explain(self, index, id, body=None, doc_type=None, params=None, headers=None :arg index: The name of the index :arg id: The document ID :arg body: The query definition using the Query DSL - :arg doc_type: The type of the document :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -869,10 +846,7 @@ def explain(self, index, id, body=None, doc_type=None, params=None, headers=None if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_explain", id) - else: - path = _make_path(index, doc_type, id, "_explain") + path = _make_path(index, "_explain", id) return self.transport.perform_request( "POST", path, params=params, headers=headers, body=body @@ -926,15 +900,13 @@ def field_caps(self, body=None, index=None, params=None, headers=None): "version", "version_type", ) - def get(self, index, id, doc_type=None, params=None, headers=None): + def get(self, index, id, params=None, headers=None): """ Returns a document. :arg index: The name of the index :arg id: The document ID - :arg doc_type: The type of the document (use `_all` to fetch the - first document matching the ID across all types) :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -958,8 +930,7 @@ def get(self, index, id, doc_type=None, params=None, headers=None): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + doc_type = "_doc" return self.transport.perform_request( "GET", _make_path(index, doc_type, id), params=params, headers=headers @@ -992,15 +963,13 @@ def get_script(self, id, params=None, headers=None): "version", "version_type", ) - def get_source(self, index, id, doc_type=None, params=None, headers=None): + def get_source(self, index, id, params=None, headers=None): """ Returns the source of a document. :arg index: The name of the index :arg id: The document ID - :arg doc_type: The type of the document; deprecated and optional - starting with 7.0 :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -1022,10 +991,7 @@ def get_source(self, index, id, doc_type=None, params=None, headers=None): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_source", id) - else: - path = _make_path(index, doc_type, id, "_source") + path = _make_path(index, "_source", id) return self.transport.perform_request( "GET", path, params=params, headers=headers @@ -1041,7 +1007,7 @@ def get_source(self, index, id, doc_type=None, params=None, headers=None): "routing", "stored_fields", ) - def mget(self, body, index=None, doc_type=None, params=None, headers=None): + def mget(self, body, index=None, params=None, headers=None): """ Allows to get multiple documents in one request. @@ -1050,7 +1016,6 @@ def mget(self, body, index=None, doc_type=None, params=None, headers=None): (containing full document information) or `ids` (when index and type is provided in the URL. :arg index: The name of the index - :arg doc_type: The type of the document :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -1072,7 +1037,7 @@ def mget(self, body, index=None, doc_type=None, params=None, headers=None): return self.transport.perform_request( "POST", - _make_path(index, doc_type, "_mget"), + _make_path(index, "_mget"), params=params, headers=headers, body=body, @@ -1087,7 +1052,7 @@ def mget(self, body, index=None, doc_type=None, params=None, headers=None): "search_type", "typed_keys", ) - def msearch(self, body, index=None, doc_type=None, params=None, headers=None): + def msearch(self, body, index=None, params=None, headers=None): """ Allows to execute several search operations in one request. @@ -1096,8 +1061,6 @@ def msearch(self, body, index=None, doc_type=None, params=None, headers=None): definition pairs), separated by newlines :arg index: A comma-separated list of index names to use as default - :arg doc_type: A comma-separated list of document types to use - as default :arg ccs_minimize_roundtrips: Indicates whether network round- trips should be minimized as part of cross-cluster search requests execution Default: true @@ -1127,7 +1090,7 @@ def msearch(self, body, index=None, doc_type=None, params=None, headers=None): body = _bulk_body(self.transport.serializer, body) return self.transport.perform_request( "POST", - _make_path(index, doc_type, "_msearch"), + _make_path(index, "_msearch"), params=params, headers=headers, body=body, @@ -1140,9 +1103,7 @@ def msearch(self, body, index=None, doc_type=None, params=None, headers=None): "search_type", "typed_keys", ) - def msearch_template( - self, body, index=None, doc_type=None, params=None, headers=None - ): + def msearch_template(self, body, index=None, params=None, headers=None): """ Allows to execute several search template operations in one request. @@ -1151,8 +1112,6 @@ def msearch_template( definition pairs), separated by newlines :arg index: A comma-separated list of index names to use as default - :arg doc_type: A comma-separated list of document types to use - as default :arg ccs_minimize_roundtrips: Indicates whether network round- trips should be minimized as part of cross-cluster search requests execution Default: true @@ -1171,7 +1130,7 @@ def msearch_template( body = _bulk_body(self.transport.serializer, body) return self.transport.perform_request( "POST", - _make_path(index, doc_type, "_msearch", "template"), + _make_path(index, "_msearch", "template"), params=params, headers=headers, body=body, @@ -1191,9 +1150,7 @@ def msearch_template( "version", "version_type", ) - def mtermvectors( - self, body=None, index=None, doc_type=None, params=None, headers=None - ): + def mtermvectors(self, body=None, index=None, params=None, headers=None): """ Returns multiple termvectors in one request. @@ -1202,7 +1159,6 @@ def mtermvectors( parameters per document here. You must at least provide a list of document ids. See documentation. :arg index: The index in which the document resides. - :arg doc_type: The type of the document. :arg field_statistics: Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified @@ -1235,10 +1191,7 @@ def mtermvectors( :arg version_type: Specific version type Valid choices: internal, external, external_gte, force """ - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_mtermvectors") - else: - path = _make_path(index, doc_type, "_mtermvectors") + path = _make_path(index, "_mtermvectors") return self.transport.perform_request( "POST", path, params=params, headers=headers, body=body @@ -1482,7 +1435,7 @@ def scroll(self, body=None, scroll_id=None, params=None, headers=None): "typed_keys", "version", ) - def search(self, body=None, index=None, doc_type=None, params=None, headers=None): + def search(self, body=None, index=None, params=None, headers=None): """ Returns results matching a query. @@ -1490,8 +1443,6 @@ def search(self, body=None, index=None, doc_type=None, params=None, headers=None :arg body: The search definition using the Query DSL :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - :arg doc_type: A comma-separated list of document types to - search; leave empty to perform the operation on all types :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -1592,7 +1543,7 @@ def search(self, body=None, index=None, doc_type=None, params=None, headers=None return self.transport.perform_request( "POST", - _make_path(index, doc_type, "_search"), + _make_path(index, "_search"), params=params, headers=headers, body=body, @@ -1647,9 +1598,7 @@ def search_shards(self, index=None, params=None, headers=None): "search_type", "typed_keys", ) - def search_template( - self, body, index=None, doc_type=None, params=None, headers=None - ): + def search_template(self, body, index=None, params=None, headers=None): """ Allows to use the Mustache language to pre-render a search definition. @@ -1657,8 +1606,6 @@ def search_template( :arg body: The search definition template and its params :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - :arg doc_type: A comma-separated list of document types to - search; leave empty to perform the operation on all types :arg allow_no_indices: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -1692,7 +1639,7 @@ def search_template( return self.transport.perform_request( "POST", - _make_path(index, doc_type, "_search", "template"), + _make_path(index, "_search", "template"), params=params, headers=headers, body=body, @@ -1711,9 +1658,7 @@ def search_template( "version", "version_type", ) - def termvectors( - self, index, body=None, doc_type=None, id=None, params=None, headers=None - ): + def termvectors(self, index, body=None, id=None, params=None, headers=None): """ Returns information and statistics about terms in the fields of a particular document. @@ -1722,7 +1667,6 @@ def termvectors( :arg index: The index in which the document resides. :arg body: Define parameters and or supply a document to get termvectors for. See documentation. - :arg doc_type: The type of the document. :arg id: The id of the document, when not specified a doc param should be supplied. :arg field_statistics: Specifies if document count, sum of @@ -1749,10 +1693,7 @@ def termvectors( if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_termvectors", id) - else: - path = _make_path(index, doc_type, id, "_termvectors") + path = _make_path(index, "_termvectors", id) return self.transport.perform_request( "POST", path, params=params, headers=headers, body=body @@ -1772,7 +1713,7 @@ def termvectors( "timeout", "wait_for_active_shards", ) - def update(self, index, id, body, doc_type=None, params=None, headers=None): + def update(self, index, id, body, params=None, headers=None): """ Updates a document with a script or partial document. @@ -1781,7 +1722,6 @@ def update(self, index, id, body, doc_type=None, params=None, headers=None): :arg id: Document ID :arg body: The request definition requires either `script` or partial `doc` - :arg doc_type: The type of the document :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -1815,10 +1755,7 @@ def update(self, index, id, body, doc_type=None, params=None, headers=None): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_update", id) - else: - path = _make_path(index, doc_type, id, "_update") + path = _make_path(index, "_update", id) return self.transport.perform_request( "POST", path, params=params, headers=headers, body=body @@ -1861,9 +1798,7 @@ def update(self, index, id, body, doc_type=None, params=None, headers=None): "wait_for_active_shards", "wait_for_completion", ) - def update_by_query( - self, index, body=None, doc_type=None, params=None, headers=None - ): + def update_by_query(self, index, body=None, params=None, headers=None): """ Performs an update on every document in the index without changing the source, for example to pick up a mapping change. @@ -1872,7 +1807,6 @@ def update_by_query( :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices :arg body: The search definition using the Query DSL - :arg doc_type: A comma-separated list of document types to search; leave empty to perform the operation on all types :arg _source: True or false to return the _source field or not, or a list of fields to return @@ -1955,7 +1889,7 @@ def update_by_query( return self.transport.perform_request( "POST", - _make_path(index, doc_type, "_update_by_query"), + _make_path(index, "_update_by_query"), params=params, headers=headers, body=body, diff --git a/opensearchpy/client/__init__.pyi b/opensearchpy/client/__init__.pyi index 455848ab..7af71e06 100644 --- a/opensearchpy/client/__init__.pyi +++ b/opensearchpy/client/__init__.pyi @@ -105,7 +105,6 @@ class OpenSearch(object): id: Any, *, body: Any, - doc_type: Optional[Any] = ..., pipeline: Optional[Any] = ..., refresh: Optional[Any] = ..., routing: Optional[Any] = ..., @@ -131,7 +130,6 @@ class OpenSearch(object): index: Any, *, body: Any, - doc_type: Optional[Any] = ..., id: Optional[Any] = ..., if_primary_term: Optional[Any] = ..., if_seq_no: Optional[Any] = ..., @@ -162,7 +160,6 @@ class OpenSearch(object): *, body: Any, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -208,7 +205,6 @@ class OpenSearch(object): *, body: Optional[Any] = ..., index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., allow_no_indices: Optional[Any] = ..., analyze_wildcard: Optional[Any] = ..., analyzer: Optional[Any] = ..., @@ -241,7 +237,6 @@ class OpenSearch(object): index: Any, id: Any, *, - doc_type: Optional[Any] = ..., if_primary_term: Optional[Any] = ..., if_seq_no: Optional[Any] = ..., refresh: Optional[Any] = ..., @@ -268,7 +263,6 @@ class OpenSearch(object): index: Any, *, body: Any, - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -357,7 +351,6 @@ class OpenSearch(object): index: Any, id: Any, *, - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -386,7 +379,6 @@ class OpenSearch(object): index: Any, id: Any, *, - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -415,7 +407,6 @@ class OpenSearch(object): id: Any, *, body: Optional[Any] = ..., - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -469,7 +460,6 @@ class OpenSearch(object): index: Any, id: Any, *, - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -516,7 +506,6 @@ class OpenSearch(object): index: Any, id: Any, *, - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -544,7 +533,6 @@ class OpenSearch(object): *, body: Any, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -571,7 +559,6 @@ class OpenSearch(object): *, body: Any, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., ccs_minimize_roundtrips: Optional[Any] = ..., max_concurrent_searches: Optional[Any] = ..., max_concurrent_shard_requests: Optional[Any] = ..., @@ -597,7 +584,6 @@ class OpenSearch(object): *, body: Any, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., ccs_minimize_roundtrips: Optional[Any] = ..., max_concurrent_searches: Optional[Any] = ..., rest_total_hits_as_int: Optional[Any] = ..., @@ -621,7 +607,6 @@ class OpenSearch(object): *, body: Optional[Any] = ..., index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., field_statistics: Optional[Any] = ..., fields: Optional[Any] = ..., ids: Optional[Any] = ..., @@ -793,7 +778,6 @@ class OpenSearch(object): *, body: Optional[Any] = ..., index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -878,7 +862,6 @@ class OpenSearch(object): *, body: Any, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., allow_no_indices: Optional[Any] = ..., ccs_minimize_roundtrips: Optional[Any] = ..., expand_wildcards: Optional[Any] = ..., @@ -910,7 +893,6 @@ class OpenSearch(object): index: Any, *, body: Optional[Any] = ..., - doc_type: Optional[Any] = ..., id: Optional[Any] = ..., field_statistics: Optional[Any] = ..., fields: Optional[Any] = ..., @@ -942,7 +924,6 @@ class OpenSearch(object): id: Any, *, body: Any, - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., @@ -973,7 +954,6 @@ class OpenSearch(object): index: Any, *, body: Optional[Any] = ..., - doc_type: Optional[Any] = ..., _source: Optional[Any] = ..., _source_excludes: Optional[Any] = ..., _source_includes: Optional[Any] = ..., diff --git a/opensearchpy/client/indices.py b/opensearchpy/client/indices.py index 4bdd1257..4ef292b1 100644 --- a/opensearchpy/client/indices.py +++ b/opensearchpy/client/indices.py @@ -332,38 +332,6 @@ def exists(self, index, params=None, headers=None): "HEAD", _make_path(index), params=params, headers=headers ) - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local") - def exists_type(self, index, doc_type, params=None, headers=None): - """ - Returns information about whether a particular document type exists. - (DEPRECATED) - - - :arg index: A comma-separated list of index names; use `_all` to - check the types across all indices - :arg doc_type: A comma-separated list of document types to check - :arg allow_no_indices: Whether to ignore if a wildcard indices - expression resolves into no concrete indices. (This includes `_all` - string or when no indices have been specified) - :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg local: Return local information, do not retrieve the state - from master node (default: false) - """ - for param in (index, doc_type): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return self.transport.perform_request( - "HEAD", - _make_path(index, "_mapping", doc_type), - params=params, - headers=headers, - ) - @query_params( "allow_no_indices", "expand_wildcards", @@ -373,7 +341,7 @@ def exists_type(self, index, doc_type, params=None, headers=None): "timeout", "write_index_only", ) - def put_mapping(self, body, index=None, doc_type=None, params=None, headers=None): + def put_mapping(self, body, index=None, params=None, headers=None): """ Updates the index mappings. @@ -382,7 +350,6 @@ def put_mapping(self, body, index=None, doc_type=None, params=None, headers=None :arg index: A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. - :arg doc_type: The name of the document type :arg allow_no_indices: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -401,12 +368,12 @@ def put_mapping(self, body, index=None, doc_type=None, params=None, headers=None if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - if doc_type not in SKIP_IN_PATH and index in SKIP_IN_PATH: + if index in SKIP_IN_PATH: index = "_all" return self.transport.perform_request( "PUT", - _make_path(index, doc_type, "_mapping"), + _make_path(index, "_mapping"), params=params, headers=headers, body=body, @@ -420,13 +387,12 @@ def put_mapping(self, body, index=None, doc_type=None, params=None, headers=None "local", "master_timeout", ) - def get_mapping(self, index=None, doc_type=None, params=None, headers=None): + def get_mapping(self, index=None, params=None, headers=None): """ Returns mappings for one or more indices. :arg index: A comma-separated list of index names - :arg doc_type: A comma-separated list of document types :arg allow_no_indices: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -443,7 +409,7 @@ def get_mapping(self, index=None, doc_type=None, params=None, headers=None): """ return self.transport.perform_request( "GET", - _make_path(index, "_mapping", doc_type), + _make_path(index, "_mapping"), params=params, headers=headers, ) @@ -456,16 +422,13 @@ def get_mapping(self, index=None, doc_type=None, params=None, headers=None): "include_type_name", "local", ) - def get_field_mapping( - self, fields, index=None, doc_type=None, params=None, headers=None - ): + def get_field_mapping(self, fields, index=None, params=None, headers=None): """ Returns mapping for one or more fields. :arg fields: A comma-separated list of fields :arg index: A comma-separated list of index names - :arg doc_type: A comma-separated list of document types :arg allow_no_indices: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -486,7 +449,7 @@ def get_field_mapping( return self.transport.perform_request( "GET", - _make_path(index, "_mapping", doc_type, "field", fields), + _make_path(index, "_mapping", "field", fields), params=params, headers=headers, ) @@ -865,9 +828,7 @@ def segments(self, index=None, params=None, headers=None): "q", "rewrite", ) - def validate_query( - self, body=None, index=None, doc_type=None, params=None, headers=None - ): + def validate_query(self, body=None, index=None, params=None, headers=None): """ Allows a user to validate a potentially expensive query without executing it. @@ -876,7 +837,6 @@ def validate_query( :arg index: A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices - :arg doc_type: A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types :arg all_shards: Execute validation on all shards instead of one @@ -905,7 +865,7 @@ def validate_query( """ return self.transport.perform_request( "POST", - _make_path(index, doc_type, "_validate", "query"), + _make_path(index, "_validate", "query"), params=params, headers=headers, body=body, diff --git a/opensearchpy/client/indices.pyi b/opensearchpy/client/indices.pyi index c56c2a5a..c1ccf0fc 100644 --- a/opensearchpy/client/indices.pyi +++ b/opensearchpy/client/indices.pyi @@ -249,34 +249,11 @@ class IndicesClient(NamespacedClient): params: Optional[MutableMapping[str, Any]] = ..., headers: Optional[MutableMapping[str, str]] = ..., ) -> bool: ... - def exists_type( - self, - index: Any, - doc_type: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> bool: ... def put_mapping( self, *, body: Any, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., allow_no_indices: Optional[Any] = ..., expand_wildcards: Optional[Any] = ..., ignore_unavailable: Optional[Any] = ..., @@ -301,7 +278,6 @@ class IndicesClient(NamespacedClient): self, *, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., allow_no_indices: Optional[Any] = ..., expand_wildcards: Optional[Any] = ..., ignore_unavailable: Optional[Any] = ..., @@ -326,7 +302,6 @@ class IndicesClient(NamespacedClient): fields: Any, *, index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., allow_no_indices: Optional[Any] = ..., expand_wildcards: Optional[Any] = ..., ignore_unavailable: Optional[Any] = ..., @@ -636,7 +611,6 @@ class IndicesClient(NamespacedClient): *, body: Optional[Any] = ..., index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., all_shards: Optional[Any] = ..., allow_no_indices: Optional[Any] = ..., analyze_wildcard: Optional[Any] = ..., diff --git a/opensearchpy/helpers/actions.py b/opensearchpy/helpers/actions.py index 70fd1853..92c53413 100644 --- a/opensearchpy/helpers/actions.py +++ b/opensearchpy/helpers/actions.py @@ -70,7 +70,6 @@ def expand_action(data): "_retry_on_conflict", "_routing", "_timestamp", - "_type", "_version", "_version_type", "if_seq_no", diff --git a/test_opensearchpy/test_async/test_server/test_helpers.py b/test_opensearchpy/test_async/test_server/test_helpers.py index 90f9ab5d..c72d3f89 100644 --- a/test_opensearchpy/test_async/test_server/test_helpers.py +++ b/test_opensearchpy/test_async/test_server/test_helpers.py @@ -879,7 +879,6 @@ async def test_children_are_reindexed_correctly( "_primary_term": 1, "_seq_no": 0, "_source": {"question_answer": "question"}, - "_type": "_doc", "_version": 1, "found": True, } == q @@ -895,7 +894,6 @@ async def test_children_are_reindexed_correctly( "some": "data", "question_answer": {"name": "answer", "parent": 42}, }, - "_type": "_doc", "_version": 1, "found": True, } == q diff --git a/test_opensearchpy/test_client/test_indices.py b/test_opensearchpy/test_client/test_indices.py index 85fdeeaa..44bd524b 100644 --- a/test_opensearchpy/test_client/test_indices.py +++ b/test_opensearchpy/test_client/test_indices.py @@ -44,7 +44,3 @@ def test_passing_empty_value_for_required_param_raises_exception(self): self.assertRaises(ValueError, self.client.indices.exists, index=None) self.assertRaises(ValueError, self.client.indices.exists, index=[]) self.assertRaises(ValueError, self.client.indices.exists, index="") - - def test_put_mapping_without_index(self): - self.client.indices.put_mapping(doc_type="doc-type", body={}) - self.assert_url_called("PUT", "/_all/doc-type/_mapping") diff --git a/test_opensearchpy/test_client/test_overrides.py b/test_opensearchpy/test_client/test_overrides.py index d71ef4b5..182c7c88 100644 --- a/test_opensearchpy/test_client/test_overrides.py +++ b/test_opensearchpy/test_client/test_overrides.py @@ -35,55 +35,30 @@ def test_create(self): self.client.create(index="test-index", id="test-id", body={}) self.assert_url_called("PUT", "/test-index/_create/test-id") - self.client.create( - index="test-index", doc_type="test-type", id="test-id", body={} - ) - self.assert_url_called("PUT", "/test-index/test-type/test-id/_create") - def test_delete(self): self.client.delete(index="test-index", id="test-id") self.assert_url_called("DELETE", "/test-index/_doc/test-id") - self.client.delete(index="test-index", doc_type="test-type", id="test-id") - self.assert_url_called("DELETE", "/test-index/test-type/test-id") - def test_exists(self): self.client.exists(index="test-index", id="test-id") self.assert_url_called("HEAD", "/test-index/_doc/test-id") - self.client.exists(index="test-index", doc_type="test-type", id="test-id") - self.assert_url_called("HEAD", "/test-index/test-type/test-id") - def test_explain(self): self.client.explain(index="test-index", id="test-id") self.assert_url_called("POST", "/test-index/_explain/test-id") - self.client.explain(index="test-index", doc_type="test-type", id="test-id") - self.assert_url_called("POST", "/test-index/test-type/test-id/_explain") - def test_get(self): self.client.get(index="test-index", id="test-id") self.assert_url_called("GET", "/test-index/_doc/test-id") - self.client.get(index="test-index", doc_type="test-type", id="test-id") - self.assert_url_called("GET", "/test-index/test-type/test-id") - def test_get_source(self): self.client.get_source(index="test-index", id="test-id") self.assert_url_called("GET", "/test-index/_source/test-id") - self.client.get_source(index="test-index", doc_type="test-type", id="test-id") - self.assert_url_called("GET", "/test-index/test-type/test-id/_source") - def test_exists_source(self): self.client.exists_source(index="test-index", id="test-id") self.assert_url_called("HEAD", "/test-index/_source/test-id") - self.client.exists_source( - index="test-index", doc_type="test-type", id="test-id" - ) - self.assert_url_called("HEAD", "/test-index/test-type/test-id/_source") - def test_index(self): self.client.index(index="test-index", body={}) self.assert_url_called("POST", "/test-index/_doc") @@ -91,20 +66,6 @@ def test_index(self): self.client.index(index="test-index", id="test-id", body={}) self.assert_url_called("PUT", "/test-index/_doc/test-id") - self.client.index(index="test-index", doc_type="test-type", body={}) - self.assert_url_called("POST", "/test-index/test-type") - - self.client.index( - index="test-index", doc_type="test-type", id="test-id", body={} - ) - self.assert_url_called("PUT", "/test-index/test-type/test-id") - - self.client.index(index="test-index", doc_type="_doc", body={}) - self.assert_url_called("POST", "/test-index/_doc", count=2) - - self.client.index(index="test-index", doc_type="_doc", id="test-id", body={}) - self.assert_url_called("PUT", "/test-index/_doc/test-id", count=2) - def test_termvectors(self): self.client.termvectors(index="test-index", body={}) self.assert_url_called("POST", "/test-index/_termvectors") @@ -112,30 +73,14 @@ def test_termvectors(self): self.client.termvectors(index="test-index", id="test-id", body={}) self.assert_url_called("POST", "/test-index/_termvectors/test-id") - self.client.termvectors(index="test-index", doc_type="test-type", body={}) - self.assert_url_called("POST", "/test-index/test-type/_termvectors") - - self.client.termvectors( - index="test-index", doc_type="test-type", id="test-id", body={} - ) - self.assert_url_called("POST", "/test-index/test-type/test-id/_termvectors") - def test_mtermvectors(self): self.client.mtermvectors(index="test-index", body={}) self.assert_url_called("POST", "/test-index/_mtermvectors") - self.client.mtermvectors(index="test-index", doc_type="test-type", body={}) - self.assert_url_called("POST", "/test-index/test-type/_mtermvectors") - def test_update(self): self.client.update(index="test-index", id="test-id", body={}) self.assert_url_called("POST", "/test-index/_update/test-id") - self.client.update( - index="test-index", doc_type="test-type", id="test-id", body={} - ) - self.assert_url_called("POST", "/test-index/test-type/test-id/_update") - def test_cluster_state(self): self.client.cluster.state() self.assert_url_called("GET", "/_cluster/state") @@ -155,19 +100,11 @@ def test_cluster_stats(self): def test_indices_put_mapping(self): self.client.indices.put_mapping(body={}) - self.assert_url_called("PUT", "/_mapping") + self.assert_url_called("PUT", "/_all/_mapping") self.client.indices.put_mapping(index="test-index", body={}) self.assert_url_called("PUT", "/test-index/_mapping") - self.client.indices.put_mapping( - index="test-index", doc_type="test-type", body={} - ) - self.assert_url_called("PUT", "/test-index/test-type/_mapping") - - self.client.indices.put_mapping(doc_type="test-type", body={}) - self.assert_url_called("PUT", "/_all/test-type/_mapping") - def test_tasks_get(self): with pytest.warns(DeprecationWarning): self.client.tasks.get() diff --git a/test_opensearchpy/test_helpers.py b/test_opensearchpy/test_helpers.py index 49a8c5bc..c4183c65 100644 --- a/test_opensearchpy/test_helpers.py +++ b/test_opensearchpy/test_helpers.py @@ -128,7 +128,6 @@ def test_expand_action_options(self): "_index", "_percolate", "_timestamp", - "_type", "if_seq_no", "if_primary_term", "parent", diff --git a/test_opensearchpy/test_server/test_helpers.py b/test_opensearchpy/test_server/test_helpers.py index 4029eff2..ea19ee82 100644 --- a/test_opensearchpy/test_server/test_helpers.py +++ b/test_opensearchpy/test_server/test_helpers.py @@ -97,12 +97,11 @@ def test_different_op_types(self): self.client.index(index="i", id=45, body={}) self.client.index(index="i", id=42, body={}) docs = [ - {"_index": "i", "_type": "_doc", "_id": 47, "f": "v"}, - {"_op_type": "delete", "_index": "i", "_type": "_doc", "_id": 45}, + {"_index": "i", "_id": 47, "f": "v"}, + {"_op_type": "delete", "_index": "i", "_id": 45}, { "_op_type": "update", "_index": "i", - "_type": "_doc", "_id": 42, "doc": {"answer": 42}, }, @@ -117,9 +116,9 @@ def test_different_op_types(self): def test_transport_error_can_becaught(self): failing_client = FailingBulkClient(self.client) docs = [ - {"_index": "i", "_type": "_doc", "_id": 47, "f": "v"}, - {"_index": "i", "_type": "_doc", "_id": 45, "f": "v"}, - {"_index": "i", "_type": "_doc", "_id": 42, "f": "v"}, + {"_index": "i", "_id": 47, "f": "v"}, + {"_index": "i", "_id": 45, "f": "v"}, + {"_index": "i", "_id": 42, "f": "v"}, ] results = list( @@ -141,7 +140,6 @@ def test_transport_error_can_becaught(self): { "index": { "_index": "i", - "_type": "_doc", "_id": 45, "data": {"f": "v"}, "error": "TransportError(599, 'Error!')", @@ -156,9 +154,9 @@ def test_rejected_documents_are_retried(self): self.client, fail_with=TransportError(429, "Rejected!", {}) ) docs = [ - {"_index": "i", "_type": "_doc", "_id": 47, "f": "v"}, - {"_index": "i", "_type": "_doc", "_id": 45, "f": "v"}, - {"_index": "i", "_type": "_doc", "_id": 42, "f": "v"}, + {"_index": "i", "_id": 47, "f": "v"}, + {"_index": "i", "_id": 45, "f": "v"}, + {"_index": "i", "_id": 42, "f": "v"}, ] results = list( helpers.streaming_bulk( @@ -184,9 +182,9 @@ def test_rejected_documents_are_retried_at_most_max_retries_times(self): ) docs = [ - {"_index": "i", "_type": "_doc", "_id": 47, "f": "v"}, - {"_index": "i", "_type": "_doc", "_id": 45, "f": "v"}, - {"_index": "i", "_type": "_doc", "_id": 42, "f": "v"}, + {"_index": "i", "_id": 47, "f": "v"}, + {"_index": "i", "_id": 45, "f": "v"}, + {"_index": "i", "_id": 42, "f": "v"}, ] results = list( helpers.streaming_bulk( @@ -286,7 +284,6 @@ def test_errors_are_reported_correctly(self): self.assertEqual(1, len(failed)) error = failed[0] self.assertEqual("42", error["index"]["_id"]) - self.assertEqual("_doc", error["index"]["_type"]) self.assertEqual("i", error["index"]["_index"]) print(error["index"]["error"]) self.assertTrue( @@ -387,7 +384,7 @@ def teardown_method(self, m): def test_order_can_be_preserved(self): bulk = [] for x in range(100): - bulk.append({"index": {"_index": "test_index", "_type": "_doc", "_id": x}}) + bulk.append({"index": {"_index": "test_index", "_id": x}}) bulk.append({"answer": x, "correct": x == 42}) self.client.bulk(bulk, refresh=True) @@ -407,7 +404,7 @@ def test_order_can_be_preserved(self): def test_all_documents_are_read(self): bulk = [] for x in range(100): - bulk.append({"index": {"_index": "test_index", "_type": "_doc", "_id": x}}) + bulk.append({"index": {"_index": "test_index", "_id": x}}) bulk.append({"answer": x, "correct": x == 42}) self.client.bulk(bulk, refresh=True) @@ -420,7 +417,7 @@ def test_all_documents_are_read(self): def test_scroll_error(self): bulk = [] for x in range(4): - bulk.append({"index": {"_index": "test_index", "_type": "_doc"}}) + bulk.append({"index": {"_index": "test_index"}}) bulk.append({"value": x}) self.client.bulk(bulk, refresh=True) @@ -554,7 +551,7 @@ def test_scan_auth_kwargs_favor_scroll_kwargs_option(self): def test_logger(self, logger_mock): bulk = [] for x in range(4): - bulk.append({"index": {"_index": "test_index", "_type": "_doc"}}) + bulk.append({"index": {"_index": "test_index"}}) bulk.append({"value": x}) self.client.bulk(bulk, refresh=True) @@ -589,7 +586,7 @@ def test_logger(self, logger_mock): def test_clear_scroll(self): bulk = [] for x in range(4): - bulk.append({"index": {"_index": "test_index", "_type": "_doc"}}) + bulk.append({"index": {"_index": "test_index"}}) bulk.append({"value": x}) self.client.bulk(bulk, refresh=True) @@ -645,7 +642,7 @@ class TestReindex(OpenSearchTestCase): def setup_method(self, _): bulk = [] for x in range(100): - bulk.append({"index": {"_index": "test_index", "_type": "_doc", "_id": x}}) + bulk.append({"index": {"_index": "test_index", "_id": x}}) bulk.append( { "answer": x, @@ -749,7 +746,6 @@ def test_children_are_reindexed_correctly(self): "_primary_term": 1, "_seq_no": 0, "_source": {"question_answer": "question"}, - "_type": "_doc", "_version": 1, "found": True, }, @@ -767,7 +763,6 @@ def test_children_are_reindexed_correctly(self): "some": "data", "question_answer": {"name": "answer", "parent": 42}, }, - "_type": "_doc", "_version": 1, "found": True, }, diff --git a/utils/templates/overrides/__init__/create b/utils/templates/overrides/__init__/create index 0f9d2f92..1db056fa 100644 --- a/utils/templates/overrides/__init__/create +++ b/utils/templates/overrides/__init__/create @@ -1,9 +1,6 @@ {% extends "base" %} {% block request %} - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_create", id) - else: - path = _make_path(index, doc_type, id, "_create") + path = _make_path(index, "_create", id) return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers, body=body) {% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/delete b/utils/templates/overrides/__init__/delete index 5e6bfd6a..b76a9ad1 100644 --- a/utils/templates/overrides/__init__/delete +++ b/utils/templates/overrides/__init__/delete @@ -1,7 +1,6 @@ {% extends "base" %} {% block request %} - if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + doc_type = "_doc" {{ super()|trim }} {% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/exists b/utils/templates/overrides/__init__/exists index 5e6bfd6a..b76a9ad1 100644 --- a/utils/templates/overrides/__init__/exists +++ b/utils/templates/overrides/__init__/exists @@ -1,7 +1,6 @@ {% extends "base" %} {% block request %} - if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + doc_type = "_doc" {{ super()|trim }} {% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/exists_source b/utils/templates/overrides/__init__/exists_source index 0ca1f55e..d6a68936 100644 --- a/utils/templates/overrides/__init__/exists_source +++ b/utils/templates/overrides/__init__/exists_source @@ -1,9 +1,6 @@ {% extends "base" %} {% block request %} - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_source", id) - else: - path = _make_path(index, doc_type, id, "_source") + path = _make_path(index, "_source", id) return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers) {% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/explain b/utils/templates/overrides/__init__/explain index 266789df..564dd691 100644 --- a/utils/templates/overrides/__init__/explain +++ b/utils/templates/overrides/__init__/explain @@ -1,9 +1,6 @@ {% extends "base" %} {% block request %} - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_explain", id) - else: - path = _make_path(index, doc_type, id, "_explain") + path = _make_path(index, "_explain", id) return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers, body=body) {% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/get b/utils/templates/overrides/__init__/get index 5e6bfd6a..b76a9ad1 100644 --- a/utils/templates/overrides/__init__/get +++ b/utils/templates/overrides/__init__/get @@ -1,7 +1,6 @@ {% extends "base" %} {% block request %} - if doc_type in SKIP_IN_PATH: - doc_type = "_doc" + doc_type = "_doc" {{ super()|trim }} {% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/get_source b/utils/templates/overrides/__init__/get_source index 0ca1f55e..d6a68936 100644 --- a/utils/templates/overrides/__init__/get_source +++ b/utils/templates/overrides/__init__/get_source @@ -1,9 +1,6 @@ {% extends "base" %} {% block request %} - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_source", id) - else: - path = _make_path(index, doc_type, id, "_source") + path = _make_path(index, "_source", id) return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers) {% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/index b/utils/templates/overrides/__init__/index index 1ac07386..ce7eb068 100644 --- a/utils/templates/overrides/__init__/index +++ b/utils/templates/overrides/__init__/index @@ -1,8 +1,6 @@ {% extends "base" %} {% block request %} - if doc_type is None: - doc_type = "_doc" - + doc_type = "_doc" return await self.transport.perform_request("POST" if id in SKIP_IN_PATH else "PUT", {% include "url" %}, params=params, headers=headers, body=body) {% endblock %} diff --git a/utils/templates/overrides/__init__/mtermvectors b/utils/templates/overrides/__init__/mtermvectors index 3798d4d2..76dedc52 100644 --- a/utils/templates/overrides/__init__/mtermvectors +++ b/utils/templates/overrides/__init__/mtermvectors @@ -1,9 +1,6 @@ {% extends "base" %} {% block request %} - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_mtermvectors") - else: - path = _make_path(index, doc_type, "_mtermvectors") + path = _make_path(index, "_mtermvectors") return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers, body=body) {% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/termvectors b/utils/templates/overrides/__init__/termvectors index eea62439..b43c2af3 100644 --- a/utils/templates/overrides/__init__/termvectors +++ b/utils/templates/overrides/__init__/termvectors @@ -1,9 +1,6 @@ {% extends "base" %} {% block request %} - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_termvectors", id) - else: - path = _make_path(index, doc_type, id, "_termvectors") + path = _make_path(index, "_termvectors", id) return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers, body=body) {% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/__init__/update b/utils/templates/overrides/__init__/update index 85ca2265..1e3051c4 100644 --- a/utils/templates/overrides/__init__/update +++ b/utils/templates/overrides/__init__/update @@ -1,9 +1,6 @@ {% extends "base" %} {% block request %} - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_update", id) - else: - path = _make_path(index, doc_type, id, "_update") + path = _make_path(index, "_update", id) return await self.transport.perform_request("{{ api.method }}", path, params=params, headers=headers, body=body) {% endblock %} \ No newline at end of file diff --git a/utils/templates/overrides/indices/put_mapping b/utils/templates/overrides/indices/put_mapping index 50a1b1b9..4439b232 100644 --- a/utils/templates/overrides/indices/put_mapping +++ b/utils/templates/overrides/indices/put_mapping @@ -1,6 +1,6 @@ {% extends "base" %} {% block request %} - if doc_type not in SKIP_IN_PATH and index in SKIP_IN_PATH: + if index in SKIP_IN_PATH: index = "_all" {{ super()|trim }}