-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b7e9fb
commit 38cd862
Showing
35 changed files
with
418 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Licensed to Elasticsearch B.V. under one or more contributor | ||
# license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright | ||
# ownership. Elasticsearch B.V. licenses this file to you under | ||
# the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../examples/async/alias_migration.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../examples/async/completion.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../examples/async/composite_agg.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../examples/async/parent_child.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../examples/async/percolate.py |
68 changes: 68 additions & 0 deletions
68
tests/test_integration/test_examples/_async/test_alias_migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Licensed to Elasticsearch B.V. under one or more contributor | ||
# license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright | ||
# ownership. Elasticsearch B.V. licenses this file to you under | ||
# the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from . import alias_migration | ||
from .alias_migration import ALIAS, PATTERN, BlogPost, migrate | ||
|
||
|
||
async def test_alias_migration(async_write_client): | ||
# create the index | ||
await alias_migration.setup() | ||
|
||
# verify that template, index, and alias has been set up | ||
assert await async_write_client.indices.exists_template(name=ALIAS) | ||
assert await async_write_client.indices.exists(index=PATTERN) | ||
assert await async_write_client.indices.exists_alias(name=ALIAS) | ||
|
||
indices = await async_write_client.indices.get(index=PATTERN) | ||
assert len(indices) == 1 | ||
index_name, _ = indices.popitem() | ||
|
||
# which means we can now save a document | ||
with open(__file__) as f: | ||
bp = BlogPost( | ||
_id=0, | ||
title="Hello World!", | ||
tags=["testing", "dummy"], | ||
content=f.read(), | ||
) | ||
await bp.save(refresh=True) | ||
|
||
assert await BlogPost.search().count() == 1 | ||
|
||
# _matches work which means we get BlogPost instance | ||
bp = (await BlogPost.search().execute())[0] | ||
assert isinstance(bp, BlogPost) | ||
assert not bp.is_published() | ||
assert "0" == bp.meta.id | ||
|
||
# create new index | ||
await migrate() | ||
|
||
indices = await async_write_client.indices.get(index=PATTERN) | ||
assert 2 == len(indices) | ||
alias = await async_write_client.indices.get(index=ALIAS) | ||
assert 1 == len(alias) | ||
assert index_name not in alias | ||
|
||
# data has been moved properly | ||
assert await BlogPost.search().count() == 1 | ||
|
||
# _matches work which means we get BlogPost instance | ||
bp = (await BlogPost.search().execute())[0] | ||
assert isinstance(bp, BlogPost) | ||
assert "0" == bp.meta.id |
34 changes: 34 additions & 0 deletions
34
tests/test_integration/test_examples/_async/test_completion.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Licensed to Elasticsearch B.V. under one or more contributor | ||
# license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright | ||
# ownership. Elasticsearch B.V. licenses this file to you under | ||
# the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
|
||
from .completion import Person | ||
|
||
|
||
async def test_person_suggests_on_all_variants_of_name(async_write_client): | ||
await Person.init(using=async_write_client) | ||
|
||
await Person(name="Honza Král", popularity=42).save(refresh=True) | ||
|
||
s = Person.search().suggest("t", "kra", completion={"field": "suggest"}) | ||
response = await s.execute() | ||
|
||
opts = response.suggest.t[0].options | ||
|
||
assert 1 == len(opts) | ||
assert opts[0]._score == 42 | ||
assert opts[0]._source.name == "Honza Král" |
Oops, something went wrong.