Compare commits

...

16 Commits

Author SHA1 Message Date
frob cbfd6b364a
Merge 3d139086c1 into 10d3af84b8 2024-11-18 16:07:43 +05:30
Markus Heiser 10d3af84b8 [fix] engine: duckduckgo - don't quote query string
The query string send to DDG must not be qouted.

The query string was URL-qouted in #4011, but the URL-qouted query string result
in unexpected *URL decoded* and other garbish results as reported in #4019
and #4020.  To test compare the results of a query like::

    !ddg Häuser und Straßen :de
    !ddg Häuser und Straßen :all
    !ddg 房屋和街道 :all
    !ddg 房屋和街道 :zh

Closed:

- [#4019] https://github.com/searxng/searxng/issues/4019
- [#4020] https://github.com/searxng/searxng/issues/4020

Related:

- [#4011] https://github.com/searxng/searxng/pull/4011

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-11-17 18:14:22 +01:00
dependabot[bot] 4b57bc3db1 [upd] pypi: Bump flask from 3.0.3 to 3.1.0
Bumps [flask](https://github.com/pallets/flask) from 3.0.3 to 3.1.0.
- [Release notes](https://github.com/pallets/flask/releases)
- [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/flask/compare/3.0.3...3.1.0)

---
updated-dependencies:
- dependency-name: flask
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-15 13:23:24 +01:00
searxng-bot a345cbbe51 [l10n] update translations from Weblate
0216898a3 - 2024-11-14 - KhietVo <KhietVo@users.noreply.translate.codeberg.org>
3293db4c8 - 2024-11-14 - return42 <return42@users.noreply.translate.codeberg.org>
574e0d683 - 2024-11-13 - lrnz2 <lrnz2@users.noreply.translate.codeberg.org>
a32d9d158 - 2024-11-08 - Aadniz <Aadniz@users.noreply.translate.codeberg.org>
2024-11-15 13:20:52 +01:00
Nicolas Dato abd9b271bc [fix] engine: duckduckgo - only uses first word of the search terms
during the revision in PR #3955 the query string was accidentally converted into
a list of words, further the query must be quoted before POSTed in the ``data``
field, see ``urllib.parse.quote_plus`` [1]

[1] https://docs.python.org/3/library/urllib.parse.html#urllib.parse.quote_plus

Closed: #4009
Co-Authored-by: @return42
2024-11-14 09:33:54 +01:00
Leo Liu dfaf5868e2 [fix] settings.yml - enabled_plugins: document to reflect default settings
Remove 'Autodetect search language', which is no longer valid, from settings,
and add 'Unit converter plugin', which is now default enabled, to settings.
2024-11-10 16:09:41 +01:00
Leo Liu b173f3a8b9 Fix scheduler.lua 2024-11-10 15:53:58 +01:00
dependabot[bot] 2fbf15eccb [upd] pypi: Bump typer-slim from 0.12.5 to 0.13.0
Bumps [typer-slim](https://github.com/fastapi/typer) from 0.12.5 to 0.13.0.
- [Release notes](https://github.com/fastapi/typer/releases)
- [Changelog](https://github.com/fastapi/typer/blob/master/docs/release-notes.md)
- [Commits](https://github.com/fastapi/typer/compare/0.12.5...0.13.0)

---
updated-dependencies:
- dependency-name: typer-slim
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-08 08:51:43 +01:00
searxng-bot 08c5f258d8 [l10n] update translations from Weblate
8d90a7e6d - 2024-11-06 - sahussawud <sahussawud@users.noreply.translate.codeberg.org>
41ee8bb0d - 2024-11-02 - laaknor <laaknor@users.noreply.translate.codeberg.org>
c1a30afab - 2024-11-02 - return42 <return42@users.noreply.translate.codeberg.org>
627ab7a8e - 2024-11-01 - zarlin <zarlin@users.noreply.translate.codeberg.org>
2024-11-08 08:45:07 +01:00
dependabot[bot] cd384a8a60 [upd] pypi: Bump selenium from 4.25.0 to 4.26.1
Bumps [selenium](https://github.com/SeleniumHQ/Selenium) from 4.25.0 to 4.26.1.
- [Release notes](https://github.com/SeleniumHQ/Selenium/releases)
- [Commits](https://github.com/SeleniumHQ/Selenium/commits)

---
updated-dependencies:
- dependency-name: selenium
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-06 10:01:13 +01:00
Markus Heiser c4055e449f [fix] issues reported by `make test.yamllint`
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-11-06 08:16:21 +01:00
Markus Heiser 2fdbf2622b [mod] lint github YAML config files
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-11-06 08:16:21 +01:00
frob 3d139086c1
Merge branch 'searxng:master' into elasticsearch-custom-query 2024-06-23 14:24:06 +02:00
Richard Lyons 4c80c2458a Check exception context for actual error message. 2024-06-22 14:02:28 +02:00
Richard Lyons 7897ad1d5a Add tests for special characters [ '"]. 2024-06-22 13:30:49 +02:00
Richard Lyons bc5068fece Fix elasticsearch custom_query. 2024-06-21 22:28:31 +02:00
25 changed files with 445 additions and 276 deletions

View File

@ -1,5 +1,5 @@
name: "Checker"
on:
on: # yamllint disable-line rule:truthy
schedule:
- cron: "0 4 * * 5"
workflow_dispatch:

View File

@ -1,5 +1,5 @@
name: "Update searx.data"
on:
on: # yamllint disable-line rule:truthy
schedule:
- cron: "59 23 28 * *"
workflow_dispatch:

View File

@ -1,6 +1,6 @@
name: Integration
on:
on: # yamllint disable-line rule:truthy
push:
branches: ["master"]
pull_request:
@ -16,62 +16,62 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ["3.9", "3.10", "3.11", "3.12",]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Ubuntu packages
run: |
sudo ./utils/searxng.sh install packages
sudo apt install firefox
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
- name: Cache Python dependencies
id: cache-python
uses: actions/cache@v3
with:
path: |
./local
./.nvm
./node_modules
key: python-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements*.txt', 'setup.py') }}
- name: Install Python dependencies
if: steps.cache-python.outputs.cache-hit != 'true'
run: |
make V=1 install
make V=1 gecko.driver
- name: Run tests
run: make V=1 ci.test
- name: Checkout
uses: actions/checkout@v4
- name: Install Ubuntu packages
run: |
sudo ./utils/searxng.sh install packages
sudo apt install firefox
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
- name: Cache Python dependencies
id: cache-python
uses: actions/cache@v3
with:
path: |
./local
./.nvm
./node_modules
key: python-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements*.txt', 'setup.py') }}
- name: Install Python dependencies
if: steps.cache-python.outputs.cache-hit != 'true'
run: |
make V=1 install
make V=1 gecko.driver
- name: Run tests
run: make V=1 ci.test
themes:
name: Themes
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Ubuntu packages
run: sudo ./utils/searxng.sh install buildhost
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'
- name: Cache Python dependencies
id: cache-python
uses: actions/cache@v3
with:
path: |
./local
./.nvm
./node_modules
key: python-ubuntu-20.04-3.12-${{ hashFiles('requirements*.txt', 'setup.py','.nvmrc', 'package.json') }}
- name: Install node dependencies
run: make V=1 node.env
- name: Build themes
run: make V=1 themes.all
- name: Checkout
uses: actions/checkout@v4
- name: Install Ubuntu packages
run: sudo ./utils/searxng.sh install buildhost
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'
- name: Cache Python dependencies
id: cache-python
uses: actions/cache@v3
with:
path: |
./local
./.nvm
./node_modules
key: python-ubuntu-20.04-3.12-${{ hashFiles('requirements*.txt', 'setup.py','.nvmrc', 'package.json') }}
- name: Install node dependencies
run: make V=1 node.env
- name: Build themes
run: make V=1 themes.all
documentation:
name: Documentation
@ -79,40 +79,40 @@ jobs:
permissions:
contents: write # for JamesIves/github-pages-deploy-action to push changes in repo
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'
persist-credentials: false
- name: Install Ubuntu packages
run: sudo ./utils/searxng.sh install buildhost
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'
- name: Cache Python dependencies
id: cache-python
uses: actions/cache@v3
with:
path: |
./local
./.nvm
./node_modules
key: python-ubuntu-20.04-3.12-${{ hashFiles('requirements*.txt', 'setup.py','.nvmrc', 'package.json') }}
- name: Build documentation
run: |
make V=1 docs.clean docs.html
- name: Deploy
if: github.ref == 'refs/heads/master'
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ github.token }}
BRANCH: gh-pages
FOLDER: dist/docs
CLEAN: true # Automatically remove deleted files from the deploy branch
SINGLE_COMMIT: True
COMMIT_MESSAGE: '[doc] build from commit ${{ github.sha }}'
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'
persist-credentials: false
- name: Install Ubuntu packages
run: sudo ./utils/searxng.sh install buildhost
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'
- name: Cache Python dependencies
id: cache-python
uses: actions/cache@v3
with:
path: |
./local
./.nvm
./node_modules
key: python-ubuntu-20.04-3.12-${{ hashFiles('requirements*.txt', 'setup.py','.nvmrc', 'package.json') }}
- name: Build documentation
run: |
make V=1 docs.clean docs.html
- name: Deploy
if: github.ref == 'refs/heads/master'
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ github.token }}
BRANCH: gh-pages
FOLDER: dist/docs
CLEAN: true # Automatically remove deleted files from the deploy branch
SINGLE_COMMIT: true
COMMIT_MESSAGE: '[doc] build from commit ${{ github.sha }}'
babel:
name: Update translations branch
@ -125,37 +125,37 @@ jobs:
permissions:
contents: write # for make V=1 weblate.push.translations
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'
token: ${{ secrets.WEBLATE_GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'
- name: Cache Python dependencies
id: cache-python
uses: actions/cache@v3
with:
path: |
./local
./.nvm
./node_modules
key: python-ubuntu-20.04-3.12-${{ hashFiles('requirements*.txt', 'setup.py','.nvmrc', 'package.json') }}
- name: weblate & git setup
env:
WEBLATE_CONFIG: ${{ secrets.WEBLATE_CONFIG }}
run: |
mkdir -p ~/.config
echo "${WEBLATE_CONFIG}" > ~/.config/weblate
git config --global user.email "searxng-bot@users.noreply.github.com"
git config --global user.name "searxng-bot"
- name: Update transations
id: update
run: |
make V=1 weblate.push.translations
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'
token: ${{ secrets.WEBLATE_GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'
- name: Cache Python dependencies
id: cache-python
uses: actions/cache@v3
with:
path: |
./local
./.nvm
./node_modules
key: python-ubuntu-20.04-3.12-${{ hashFiles('requirements*.txt', 'setup.py','.nvmrc', 'package.json') }}
- name: weblate & git setup
env:
WEBLATE_CONFIG: ${{ secrets.WEBLATE_CONFIG }}
run: |
mkdir -p ~/.config
echo "${WEBLATE_CONFIG}" > ~/.config/weblate
git config --global user.email "searxng-bot@users.noreply.github.com"
git config --global user.name "searxng-bot"
- name: Update transations
id: update
run: |
make V=1 weblate.push.translations
dockers:
name: Docker

View File

@ -1,5 +1,5 @@
name: "Security checks"
on:
on: # yamllint disable-line rule:truthy
schedule:
- cron: "42 05 * * *"
workflow_dispatch:

View File

@ -1,5 +1,5 @@
name: "Update translations"
on:
on: # yamllint disable-line rule:truthy
schedule:
- cron: "05 07 * * 5"
workflow_dispatch:
@ -10,50 +10,50 @@ jobs:
runs-on: ubuntu-20.04
if: ${{ github.repository_owner == 'searxng' && github.ref == 'refs/heads/master' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'
token: ${{ secrets.WEBLATE_GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'
- name: Cache Python dependencies
id: cache-python
uses: actions/cache@v3
with:
path: |
./local
./.nvm
./node_modules
key: python-ubuntu-20.04-3.12-${{ hashFiles('requirements*.txt', 'setup.py','.nvmrc', 'package.json') }}
- name: weblate & git setup
env:
WEBLATE_CONFIG: ${{ secrets.WEBLATE_CONFIG }}
run: |
mkdir -p ~/.config
echo "${WEBLATE_CONFIG}" > ~/.config/weblate
git config --global user.email "searxng-bot@users.noreply.github.com"
git config --global user.name "searxng-bot"
- name: Merge and push transation updates
run: |
make V=1 weblate.translations.commit
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.WEBLATE_GITHUB_TOKEN }}
commit-message: '[l10n] update translations from Weblate'
committer: searxng-bot <searxng-bot@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: translations_update
delete-branch: true
draft: false
title: '[l10n] update translations from Weblate'
body: |
update translations from Weblate
labels: |
translation
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'
token: ${{ secrets.WEBLATE_GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'
- name: Cache Python dependencies
id: cache-python
uses: actions/cache@v3
with:
path: |
./local
./.nvm
./node_modules
key: python-ubuntu-20.04-3.12-${{ hashFiles('requirements*.txt', 'setup.py','.nvmrc', 'package.json') }}
- name: weblate & git setup
env:
WEBLATE_CONFIG: ${{ secrets.WEBLATE_CONFIG }}
run: |
mkdir -p ~/.config
echo "${WEBLATE_CONFIG}" > ~/.config/weblate
git config --global user.email "searxng-bot@users.noreply.github.com"
git config --global user.name "searxng-bot"
- name: Merge and push transation updates
run: |
make V=1 weblate.translations.commit
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.WEBLATE_GITHUB_TOKEN }}
commit-message: '[l10n] update translations from Weblate'
committer: searxng-bot <searxng-bot@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: translations_update
delete-branch: true
draft: false
title: '[l10n] update translations from Weblate'
body: |
update translations from Weblate
labels: |
translation

2
manage
View File

@ -57,7 +57,7 @@ while IFS= read -r line; do
if [ "$line" != "tests/unit/settings/syntaxerror_settings.yml" ]; then
YAMLLINT_FILES+=("$line")
fi
done <<< "$(git ls-files './tests/*.yml' './searx/*.yml' './utils/templates/etc/searxng/*.yml')"
done <<< "$(git ls-files './tests/*.yml' './searx/*.yml' './utils/templates/etc/searxng/*.yml' '.github/*.yml' '.github/*/*.yml')"
RST_FILES=(
'README.rst'

View File

@ -4,7 +4,7 @@ cov-core==1.15.0
black==24.3.0
pylint==3.3.1
splinter==0.21.0
selenium==4.25.0
selenium==4.26.1
Pallets-Sphinx-Themes==2.3.0
Sphinx==7.4.7
sphinx-issues==5.0.0

View File

@ -1,7 +1,7 @@
certifi==2024.8.30
babel==2.16.0
flask-babel==4.0.0
flask==3.0.3
flask==3.1.0
jinja2==3.1.4
lxml==5.3.0
pygments==2.18.0
@ -18,4 +18,4 @@ fasttext-predict==0.9.2.2
tomli==2.0.2; python_version < '3.11'
msgspec==0.18.6
eval_type_backport; python_version < '3.9'
typer-slim==0.12.5
typer-slim==0.13.0

View File

@ -245,10 +245,12 @@ def request(query, params):
# Advanced search syntax ends in CAPTCHA
# https://duckduckgo.com/duckduckgo-help-pages/results/syntax/
query = [
x.removeprefix("site:").removeprefix("intitle:").removeprefix("inurl:").removeprefix("filetype:")
for x in query.split()
]
query = " ".join(
[
x.removeprefix("site:").removeprefix("intitle:").removeprefix("inurl:").removeprefix("filetype:")
for x in query.split()
]
)
eng_region = traits.get_region(params['searxng_locale'], traits.all_locale)
if eng_region == "wt-wt":
# https://html.duckduckgo.com/html sets an empty value for "all".
@ -379,7 +381,11 @@ def response(resp):
zero_click_info_xpath = '//div[@id="zero_click_abstract"]'
zero_click = extract_text(eval_xpath(doc, zero_click_info_xpath)).strip()
if zero_click and "Your IP address is" not in zero_click and "Your user agent:" not in zero_click:
if zero_click and (
"Your IP address is" not in zero_click
and "Your user agent:" not in zero_click
and "URL Decoded:" not in zero_click
):
current_query = resp.search_params["data"].get("q")
results.append(

View File

@ -135,14 +135,38 @@ def _terms_query(query):
def _custom_query(query):
key, value = query.split(':')
custom_query = custom_query_json
key = value = None
if any(placeholder in custom_query_json for placeholder in ["{{KEY}}", "{{VALUE}}", "{{VALUES}}"]):
try:
key, value = query.split(':', maxsplit=1)
except Exception as e:
raise ValueError('query format must be "key:value"') from e
if not key:
raise ValueError('empty key from "key:value" query')
try:
custom_query = loads(custom_query_json)
except Exception as e:
raise ValueError('invalid custom_query string') from e
return _custom_query_r(query, key, value, custom_query)
def _custom_query_r(query, key, value, custom_query):
new_query = {}
for query_key, query_value in custom_query.items():
if query_key == '{{KEY}}':
custom_query[key] = custom_query.pop(query_key)
if query_value == '{{VALUE}}':
custom_query[query_key] = value
return custom_query
query_key = key
if isinstance(query_value, dict):
query_value = _custom_query_r(query, key, value, query_value)
elif query_value == '{{VALUE}}':
query_value = value
elif query_value == '{{VALUES}}':
query_value = value.split(',')
elif query_value == '{{QUERY}}':
query_value = query
new_query[query_key] = query_value
return new_query
def response(resp):

View File

@ -20,7 +20,7 @@ if (next_call_ts == false or next_call_ts == nil) then
-- 2/ the next call is a random time between start_after_from and start_after_to
local initial_delay = math.random(start_after_from, start_after_to)
redis.call('SET', redis_key, now + initial_delay)
return { false, delay }
return { false, initial_delay }
end
-- next_call_ts is defined

View File

@ -226,15 +226,12 @@ outgoing:
# - 'Hash plugin'
# - 'Self Information'
# - 'Tracker URL remover'
# - 'Unit converter plugin'
# - 'Ahmia blacklist' # activation depends on outgoing.using_tor_proxy
# # these plugins are disabled if nothing is configured ..
# - 'Hostnames plugin' # see 'hostnames' configuration below
# - 'Open Access DOI rewrite'
# - 'Tor check plugin'
# # Read the docs before activate: auto-detection of the language could be
# # detrimental to users expectations / users can activate the plugin in the
# # preferences if they want.
# - 'Autodetect search language'
# Configuration of the "Hostnames plugin":
#

View File

@ -39,9 +39,8 @@ msgstr ""
"Project-Id-Version: searx\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
"PO-Revision-Date: 2024-10-26 21:13+0000\n"
"Last-Translator: Atul_Eterno <Atul_Eterno@users.noreply.translate.codeberg."
"org>\n"
"PO-Revision-Date: 2024-11-14 14:07+0000\n"
"Last-Translator: return42 <return42@users.noreply.translate.codeberg.org>\n"
"Language-Team: Spanish <https://translate.codeberg.org/projects/searxng/"
"searxng/es/>\n"
"Language: es\n"
@ -1246,11 +1245,11 @@ msgstr "Tiempo máximo"
#: searx/templates/simple/preferences/favicon.html:2
msgid "Favicon Resolver"
msgstr ""
msgstr "Buscador de favicon"
#: searx/templates/simple/preferences/favicon.html:15
msgid "Display favicons near search results"
msgstr ""
msgstr "Mostrar los favicons al lado de los resultados de búsqueda"
#: searx/templates/simple/preferences/footer.html:2
msgid ""

View File

@ -28,13 +28,14 @@
# unoyoa <unoyoa@users.noreply.translate.codeberg.org>, 2024.
# tiziodcaio <tiziodcaio@users.noreply.translate.codeberg.org>, 2024.
# Fabio_Perri <Fabio_Perri@users.noreply.translate.codeberg.org>, 2024.
# lrnz2 <lrnz2@users.noreply.translate.codeberg.org>, 2024.
msgid ""
msgstr ""
"Project-Id-Version: searx\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
"PO-Revision-Date: 2024-10-08 13:41+0000\n"
"Last-Translator: return42 <return42@users.noreply.translate.codeberg.org>\n"
"PO-Revision-Date: 2024-11-14 02:16+0000\n"
"Last-Translator: lrnz2 <lrnz2@users.noreply.translate.codeberg.org>\n"
"Language-Team: Italian <https://translate.codeberg.org/projects/searxng/"
"searxng/it/>\n"
"Language: it\n"
@ -42,13 +43,13 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.7.2\n"
"X-Generator: Weblate 5.8.1\n"
"Generated-By: Babel 2.16.0\n"
#. CONSTANT_NAMES['NO_SUBGROUPING']
#: searx/searxng.msg
msgid "without further subgrouping"
msgstr "senza altri sottogruppi"
msgstr "senza altri sottogruppamenti"
#. CONSTANT_NAMES['DEFAULT_CATEGORY']
#: searx/searxng.msg
@ -73,7 +74,7 @@ msgstr "musica"
#. CATEGORY_NAMES['SOCIAL_MEDIA']
#: searx/searxng.msg
msgid "social media"
msgstr "social"
msgstr "social media"
#. CATEGORY_NAMES['IMAGES']
#: searx/searxng.msg
@ -113,7 +114,7 @@ msgstr "mappa"
#. CATEGORY_NAMES['ONIONS']
#: searx/searxng.msg
msgid "onions"
msgstr "onion"
msgstr "cipolle"
#. CATEGORY_NAMES['SCIENCE']
#: searx/searxng.msg
@ -133,7 +134,7 @@ msgstr "dizionari"
#. CATEGORY_GROUPS['LYRICS']
#: searx/searxng.msg
msgid "lyrics"
msgstr "testi musicali"
msgstr "testo musicale"
#. CATEGORY_GROUPS['PACKAGES']
#: searx/searxng.msg
@ -148,12 +149,12 @@ msgstr "d&r"
#. CATEGORY_GROUPS['REPOS']
#: searx/searxng.msg
msgid "repos"
msgstr "ripostigli"
msgstr "repos"
#. CATEGORY_GROUPS['SOFTWARE_WIKIS']
#: searx/searxng.msg
msgid "software wikis"
msgstr "wiki software"
msgstr "wiki del software"
#. CATEGORY_GROUPS['WEB']
#: searx/searxng.msg
@ -193,7 +194,7 @@ msgstr "Tempo di attività"
#. BRAND_CUSTOM_LINKS['ABOUT']
#: searx/searxng.msg searx/templates/simple/base.html:50
msgid "About"
msgstr "A proposito"
msgstr "Al riguardo"
#. WEATHER_TERMS['AVERAGE TEMP.']
#: searx/engines/wttr.py:32 searx/searxng.msg

View File

@ -10,21 +10,23 @@
# return42 <return42@users.noreply.translate.codeberg.org>, 2024.
# omfj <omfj@users.noreply.translate.codeberg.org>, 2024.
# combwizard <combwizard@users.noreply.translate.codeberg.org>, 2024.
# laaknor <laaknor@users.noreply.translate.codeberg.org>, 2024.
# Aadniz <Aadniz@users.noreply.translate.codeberg.org>, 2024.
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
"PO-Revision-Date: 2024-10-04 21:35+0000\n"
"Last-Translator: combwizard "
"<combwizard@users.noreply.translate.codeberg.org>\n"
"PO-Revision-Date: 2024-11-09 12:07+0000\n"
"Last-Translator: Aadniz <Aadniz@users.noreply.translate.codeberg.org>\n"
"Language-Team: Norwegian Bokmål <https://translate.codeberg.org/projects/"
"searxng/searxng/nb_NO/>\n"
"Language: nb_NO\n"
"Language-Team: Norwegian Bokmål "
"<https://translate.codeberg.org/projects/searxng/searxng/nb_NO/>\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.8.1\n"
"Generated-By: Babel 2.16.0\n"
#. CONSTANT_NAMES['NO_SUBGROUPING']
@ -191,13 +193,13 @@ msgstr "Skydekke"
#: searx/engines/duckduckgo_weather.py:45 searx/engines/wttr.py:51
#: searx/searxng.msg
msgid "Condition"
msgstr ""
msgstr "Betingelse"
#. WEATHER_TERMS['CURRENT CONDITION']
#: searx/engines/duckduckgo_weather.py:118 searx/engines/wttr.py:104
#: searx/searxng.msg
msgid "Current condition"
msgstr ""
msgstr "Nåværende betingelse"
#. WEATHER_TERMS['EVENING']
#: searx/engines/wttr.py:100 searx/searxng.msg
@ -220,13 +222,13 @@ msgstr "Luftfuktighet"
#: searx/engines/duckduckgo_weather.py:77 searx/engines/wttr.py:34
#: searx/searxng.msg
msgid "Max temp."
msgstr ""
msgstr "Maks temp."
#. WEATHER_TERMS['MIN TEMP.']
#: searx/engines/duckduckgo_weather.py:73 searx/engines/wttr.py:33
#: searx/searxng.msg
msgid "Min temp."
msgstr ""
msgstr "Min temp."
#. WEATHER_TERMS['MORNING']
#: searx/engines/wttr.py:100 searx/searxng.msg
@ -333,17 +335,17 @@ msgstr "opphavsmann"
#. SOCIAL_MEDIA_TERMS['THREAD OPEN']
#: searx/engines/discourse.py:149 searx/searxng.msg
msgid "open"
msgstr ""
msgstr "åpen"
#. SOCIAL_MEDIA_TERMS['THREAD CLOSED']
#: searx/engines/discourse.py:149 searx/searxng.msg
msgid "closed"
msgstr ""
msgstr "lukket"
#. SOCIAL_MEDIA_TERMS['THREAD ANSWERED']
#: searx/engines/discourse.py:160 searx/searxng.msg
msgid "answered"
msgstr ""
msgstr "svart på"
#: searx/webapp.py:332
msgid "No item found"
@ -420,7 +422,7 @@ msgstr "tilgang nektet"
#: searx/webutils.py:60
msgid "server API error"
msgstr "Tjener-API-feil"
msgstr "server API feil"
#: searx/webutils.py:79
msgid "Suspended"
@ -452,7 +454,7 @@ msgstr "Regn ut {functions} av parameterne"
#: searx/engines/mozhi.py:57
msgid "Synonyms"
msgstr ""
msgstr "Synonymer"
#: searx/engines/openstreetmap.py:159
msgid "Get directions"
@ -527,7 +529,7 @@ msgstr "Filkvalitet"
#: searx/plugins/calculator.py:14
msgid "Calculate mathematical expressions via the search bar"
msgstr ""
msgstr "Kalkuler matematiske uttrykk via søkebaren"
#: searx/plugins/hash_plugin.py:10
msgid "Converts strings to different hash digests."
@ -571,7 +573,7 @@ msgstr ""
#: searx/plugins/self_info.py:28
msgid "Your IP is: "
msgstr ""
msgstr "Din IP er "
#: searx/plugins/self_info.py:31
msgid "Your user-agent is: "
@ -579,16 +581,16 @@ msgstr ""
#: searx/plugins/tor_check.py:24
msgid "Tor check plugin"
msgstr "Tor sjekk pluggin"
msgstr "Tor sjekking plugin"
#: searx/plugins/tor_check.py:27
msgid ""
"This plugin checks if the address of the request is a Tor exit-node, and "
"informs the user if it is; like check.torproject.org, but from SearXNG."
msgstr ""
"Denne plugin sjekker om adressen til forespørselen er en Tor utgangsnode,"
" og informerer brukeren om den er det; som check.torproject.org, men fra "
"SearXNG."
"Denne plugin-en sjekker om adressen til forespørselen er en Tor utgangsnode, "
"og informerer brukeren om den er det; slik som check.torproject.org gjør, "
"men fra SearXNG."
#: searx/plugins/tor_check.py:61
msgid ""
@ -620,7 +622,7 @@ msgstr "Fjern sporer-argumenter fra returnert nettadresse"
#: searx/plugins/unit_converter.py:29
msgid "Convert between units"
msgstr ""
msgstr "Konverter mellom forskjellige enheter"
#: searx/templates/simple/404.html:4
msgid "Page not found"
@ -687,7 +689,7 @@ msgstr "Lengde"
#: searx/templates/simple/macros.html:41
msgid "Views"
msgstr ""
msgstr "Visninger"
#: searx/templates/simple/macros.html:42
#: searx/templates/simple/result_templates/files.html:34
@ -945,7 +947,7 @@ msgstr "Meldinger fra søkemotorene"
#: searx/templates/simple/elements/engines_msg.html:7
msgid "seconds"
msgstr ""
msgstr "sekunder"
#: searx/templates/simple/elements/search_url.html:3
msgid "Search URL"
@ -1051,7 +1053,7 @@ msgstr "Det er ingen flere resultater. Du kan prøve å:"
#: searx/templates/simple/messages/no_results.html:19
msgid "Refresh the page."
msgstr "oppfrisk siden"
msgstr "oppfrisk siden."
#: searx/templates/simple/messages/no_results.html:20
msgid "Search for another query or select another category (above)."
@ -1067,7 +1069,7 @@ msgstr "Bytt til en annen instans:"
#: searx/templates/simple/messages/no_results.html:24
msgid "Search for another query or select another category."
msgstr ""
msgstr "Oppgi et annet søkeord eller velg en annen kategori."
#: searx/templates/simple/messages/no_results.html:25
msgid "Go back to the previous page using the previous page button."
@ -1193,11 +1195,11 @@ msgstr ""
#: searx/templates/simple/preferences/engines.html:15
msgid "Enable all"
msgstr ""
msgstr "Aktiver alle"
#: searx/templates/simple/preferences/engines.html:16
msgid "Disable all"
msgstr ""
msgstr "Deaktiver alle"
#: searx/templates/simple/preferences/engines.html:25
msgid "!bang"
@ -1882,4 +1884,3 @@ msgstr "skjul video"
#~ msgid "Engines cannot retrieve results"
#~ msgstr "Søkemotorer kan ikke motta resultater"

View File

@ -23,13 +23,14 @@
# notlmutsaers <notlmutsaers@users.noreply.translate.codeberg.org>, 2024.
# return42 <return42@users.noreply.translate.codeberg.org>, 2024.
# ljansen <ljansen@users.noreply.translate.codeberg.org>, 2024.
# zarlin <zarlin@users.noreply.translate.codeberg.org>, 2024.
msgid ""
msgstr ""
"Project-Id-Version: searx\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
"PO-Revision-Date: 2024-10-28 21:07+0000\n"
"Last-Translator: ljansen <ljansen@users.noreply.translate.codeberg.org>\n"
"PO-Revision-Date: 2024-11-02 04:00+0000\n"
"Last-Translator: zarlin <zarlin@users.noreply.translate.codeberg.org>\n"
"Language-Team: Dutch <https://translate.codeberg.org/projects/searxng/"
"searxng/nl/>\n"
"Language: nl\n"
@ -493,7 +494,7 @@ msgstr "stemmen"
#: searx/engines/radio_browser.py:107
msgid "clicks"
msgstr "clicks"
msgstr "klikken"
#: searx/engines/seekr.py:193 searx/engines/yummly.py:71
#: searx/engines/zlibrary.py:137
@ -662,7 +663,7 @@ msgstr "Voorkeuren"
#: searx/templates/simple/base.html:68
msgid "Powered by"
msgstr "Zoekmachine"
msgstr "Verzorgd door"
#: searx/templates/simple/base.html:68
msgid "a privacy-respecting, open metasearch engine"
@ -1069,7 +1070,7 @@ msgstr "Er zijn geen resultaten meer. U kunt proberen om:"
#: searx/templates/simple/messages/no_results.html:19
msgid "Refresh the page."
msgstr "Ververs de pagina"
msgstr "Ververs de pagina."
#: searx/templates/simple/messages/no_results.html:20
msgid "Search for another query or select another category (above)."
@ -1235,9 +1236,8 @@ msgid "Max time"
msgstr "Max. duur"
#: searx/templates/simple/preferences/favicon.html:2
#, fuzzy
msgid "Favicon Resolver"
msgstr "favicon-resolver"
msgstr "Favicon Oplosser"
#: searx/templates/simple/preferences/favicon.html:15
msgid "Display favicons near search results"

View File

@ -8,21 +8,23 @@
# return42 <return42@users.noreply.translate.codeberg.org>, 2024.
# abhabongse <abhabongse@users.noreply.translate.codeberg.org>, 2024.
# tutakrab <tutakrab@users.noreply.translate.codeberg.org>, 2024.
# sahussawud <sahussawud@users.noreply.translate.codeberg.org>, 2024.
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
"PO-Revision-Date: 2024-10-02 16:10+0000\n"
"Last-Translator: tutakrab <tutakrab@users.noreply.translate.codeberg.org>"
"PO-Revision-Date: 2024-11-06 07:26+0000\n"
"Last-Translator: sahussawud <sahussawud@users.noreply.translate.codeberg.org>"
"\n"
"Language-Team: Thai <https://translate.codeberg.org/projects/searxng/searxng/"
"th/>\n"
"Language: th\n"
"Language-Team: Thai "
"<https://translate.codeberg.org/projects/searxng/searxng/th/>\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 5.8.1\n"
"Generated-By: Babel 2.16.0\n"
#. CONSTANT_NAMES['NO_SUBGROUPING']
@ -163,7 +165,7 @@ msgstr "มืด"
#. STYLE_NAMES['BLACK']
#: searx/searxng.msg
msgid "black"
msgstr ""
msgstr "สีดำ"
#. BRAND_CUSTOM_LINKS['UPTIME']
#: searx/searxng.msg
@ -331,12 +333,12 @@ msgstr "ผู้เขียน"
#. SOCIAL_MEDIA_TERMS['THREAD OPEN']
#: searx/engines/discourse.py:149 searx/searxng.msg
msgid "open"
msgstr ""
msgstr "สร้าง"
#. SOCIAL_MEDIA_TERMS['THREAD CLOSED']
#: searx/engines/discourse.py:149 searx/searxng.msg
msgid "closed"
msgstr ""
msgstr "ลบ"
#. SOCIAL_MEDIA_TERMS['THREAD ANSWERED']
#: searx/engines/discourse.py:160 searx/searxng.msg
@ -450,7 +452,7 @@ msgstr "คำนวณ {functions} จากอาร์กิวเมนต
#: searx/engines/mozhi.py:57
msgid "Synonyms"
msgstr ""
msgstr "คำเหมือน"
#: searx/engines/openstreetmap.py:159
msgid "Get directions"
@ -538,8 +540,9 @@ msgid "hash digest"
msgstr "แฮชย่อย"
#: searx/plugins/hostnames.py:103
#, fuzzy
msgid "Hostnames plugin"
msgstr ""
msgstr "ชื่อโฮส ปลั๊กอิน"
#: searx/plugins/hostnames.py:104
msgid "Rewrite hostnames, remove results or prioritize them based on the hostname"
@ -1698,4 +1701,3 @@ msgstr "ซ่อนวิดีโอ"
#~ msgid "Engines cannot retrieve results"
#~ msgstr "เครื่องมือไม่สามารถดึงผลลัพธ์ได้"

View File

@ -10,13 +10,14 @@
# return42 <return42@users.noreply.translate.codeberg.org>, 2024.
# vducong <vducong@users.noreply.translate.codeberg.org>, 2024.
# tvminh19 <tvminh19@users.noreply.translate.codeberg.org>, 2024.
# KhietVo <KhietVo@users.noreply.translate.codeberg.org>, 2024.
msgid ""
msgstr ""
"Project-Id-Version: searx\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
"PO-Revision-Date: 2024-10-26 21:13+0000\n"
"Last-Translator: return42 <return42@users.noreply.translate.codeberg.org>\n"
"PO-Revision-Date: 2024-11-14 14:07+0000\n"
"Last-Translator: KhietVo <KhietVo@users.noreply.translate.codeberg.org>\n"
"Language-Team: Vietnamese <https://translate.codeberg.org/projects/searxng/"
"searxng/vi/>\n"
"Language: vi\n"
@ -166,7 +167,7 @@ msgstr "Tối"
#. STYLE_NAMES['BLACK']
#: searx/searxng.msg
msgid "black"
msgstr ""
msgstr "màu đen"
#. BRAND_CUSTOM_LINKS['UPTIME']
#: searx/searxng.msg
@ -198,7 +199,7 @@ msgstr "Điều kiện"
#: searx/engines/duckduckgo_weather.py:118 searx/engines/wttr.py:104
#: searx/searxng.msg
msgid "Current condition"
msgstr ""
msgstr "tình hình hiện tại"
#. WEATHER_TERMS['EVENING']
#: searx/engines/wttr.py:100 searx/searxng.msg
@ -209,25 +210,25 @@ msgstr "Buổi chiều"
#: searx/engines/duckduckgo_weather.py:53 searx/engines/open_meteo.py:81
#: searx/engines/wttr.py:59 searx/searxng.msg
msgid "Feels like"
msgstr ""
msgstr "Cảm thấy"
#. WEATHER_TERMS['HUMIDITY']
#: searx/engines/duckduckgo_weather.py:64 searx/engines/open_meteo.py:93
#: searx/engines/wttr.py:68 searx/searxng.msg
msgid "Humidity"
msgstr ""
msgstr "Độ ẩm"
#. WEATHER_TERMS['MAX TEMP.']
#: searx/engines/duckduckgo_weather.py:77 searx/engines/wttr.py:34
#: searx/searxng.msg
msgid "Max temp."
msgstr ""
msgstr "Nhiệt độ tối đa"
#. WEATHER_TERMS['MIN TEMP.']
#: searx/engines/duckduckgo_weather.py:73 searx/engines/wttr.py:33
#: searx/searxng.msg
msgid "Min temp."
msgstr ""
msgstr "Nhiệt độ thấp nhất"
#. WEATHER_TERMS['MORNING']
#: searx/engines/wttr.py:100 searx/searxng.msg
@ -247,37 +248,37 @@ msgstr "Buổi trưa"
#. WEATHER_TERMS['PRESSURE']
#: searx/engines/open_meteo.py:95 searx/searxng.msg
msgid "Pressure"
msgstr ""
msgstr "Áp suất"
#. WEATHER_TERMS['SUNRISE']
#: searx/engines/duckduckgo_weather.py:81 searx/engines/wttr.py:36
#: searx/searxng.msg
msgid "Sunrise"
msgstr ""
msgstr "Mặt trời mọc"
#. WEATHER_TERMS['SUNSET']
#: searx/engines/duckduckgo_weather.py:82 searx/engines/wttr.py:37
#: searx/searxng.msg
msgid "Sunset"
msgstr ""
msgstr "mặt trời lặn"
#. WEATHER_TERMS['TEMPERATURE']
#: searx/engines/duckduckgo_weather.py:48 searx/engines/open_meteo.py:76
#: searx/engines/wttr.py:55 searx/searxng.msg
msgid "Temperature"
msgstr ""
msgstr "Nhiệt độ"
#. WEATHER_TERMS['UV INDEX']
#: searx/engines/duckduckgo_weather.py:80 searx/engines/wttr.py:35
#: searx/searxng.msg
msgid "UV index"
msgstr ""
msgstr "Chỉ số UV"
#. WEATHER_TERMS['VISIBILITY']
#: searx/engines/duckduckgo_weather.py:62 searx/engines/wttr.py:66
#: searx/searxng.msg
msgid "Visibility"
msgstr ""
msgstr "Tầm nhìn"
#. WEATHER_TERMS['WIND']
#: searx/engines/duckduckgo_weather.py:58 searx/engines/open_meteo.py:86
@ -288,12 +289,12 @@ msgstr "Gió"
#. SOCIAL_MEDIA_TERMS['SUBSCRIBERS']
#: searx/engines/lemmy.py:85 searx/searxng.msg
msgid "subscribers"
msgstr ""
msgstr "người đăng ký"
#. SOCIAL_MEDIA_TERMS['POSTS']
#: searx/engines/lemmy.py:86 searx/searxng.msg
msgid "posts"
msgstr ""
msgstr "những bài đăng"
#. SOCIAL_MEDIA_TERMS['ACTIVE USERS']
#: searx/engines/lemmy.py:87 searx/searxng.msg
@ -309,42 +310,42 @@ msgstr ""
#. SOCIAL_MEDIA_TERMS['USER']
#: searx/engines/lemmy.py:129 searx/engines/lemmy.py:164 searx/searxng.msg
msgid "user"
msgstr ""
msgstr "người dùng"
#. SOCIAL_MEDIA_TERMS['COMMUNITY']
#: searx/engines/lemmy.py:131 searx/engines/lemmy.py:165 searx/searxng.msg
msgid "community"
msgstr ""
msgstr "cộng đồng"
#. SOCIAL_MEDIA_TERMS['POINTS']
#: searx/engines/hackernews.py:78 searx/searxng.msg
msgid "points"
msgstr ""
msgstr "điểm"
#. SOCIAL_MEDIA_TERMS['TITLE']
#: searx/searxng.msg
msgid "title"
msgstr ""
msgstr "tiêu đề"
#. SOCIAL_MEDIA_TERMS['AUTHOR']
#: searx/engines/hackernews.py:81 searx/searxng.msg
msgid "author"
msgstr ""
msgstr "tác giả"
#. SOCIAL_MEDIA_TERMS['THREAD OPEN']
#: searx/engines/discourse.py:149 searx/searxng.msg
msgid "open"
msgstr ""
msgstr "mở"
#. SOCIAL_MEDIA_TERMS['THREAD CLOSED']
#: searx/engines/discourse.py:149 searx/searxng.msg
msgid "closed"
msgstr ""
msgstr "đóng"
#. SOCIAL_MEDIA_TERMS['THREAD ANSWERED']
#: searx/engines/discourse.py:160 searx/searxng.msg
msgid "answered"
msgstr ""
msgstr "đã trả lời"
#: searx/webapp.py:332
msgid "No item found"
@ -529,7 +530,7 @@ msgstr "Chất lượng tệp"
#: searx/plugins/calculator.py:14
msgid "Calculate mathematical expressions via the search bar"
msgstr ""
msgstr "Tính toán bằng thanh tìm kiếm"
#: searx/plugins/hash_plugin.py:10
msgid "Converts strings to different hash digests."
@ -540,12 +541,14 @@ msgid "hash digest"
msgstr "hash băm"
#: searx/plugins/hostnames.py:103
#, fuzzy
msgid "Hostnames plugin"
msgstr ""
msgstr "Mấy chủ bổ trợ"
#: searx/plugins/hostnames.py:104
msgid "Rewrite hostnames, remove results or prioritize them based on the hostname"
msgstr ""
"Viết lại máy chủ, xoá các kểt quả tìm kiếm hoặc sắp xếp dựa trên máy chủ"
#: searx/plugins/oa_doi_rewrite.py:12
msgid "Open Access DOI rewrite"
@ -571,7 +574,7 @@ msgstr "Hiện IP của bạn khi gõ \"ip\" và hiện user agent khi gõ \"use
#: searx/plugins/self_info.py:28
msgid "Your IP is: "
msgstr ""
msgstr "Địa chỉ IP của bạn: "
#: searx/plugins/self_info.py:31
msgid "Your user-agent is: "

View File

@ -0,0 +1,136 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring
'''
searx is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
searx is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with searx. If not, see < http://www.gnu.org/licenses/ >.
'''
from json import loads
from searx.engines import elasticsearch as elasticsearch_engine
from tests import SearxTestCase
class TestElasticsearchEngine(SearxTestCase): # pylint: disable=missing-class-docstring
default_params = {"headers": {}}
def test_url_settings(self):
elasticsearch_engine.base_url = 'http://es:12345'
elasticsearch_engine.index = 'index'
params = elasticsearch_engine.request("city:berlin", self.default_params)
self.assertEqual(params["url"], "http://es:12345/index/_search")
def test_basic_queries(self):
queries = [
['match', 'field:stuff', '{"query": {"match": {"field": {"query": "stuff"}}}}'],
['simple_query_string', 'stuff', '{"query": {"simple_query_string": {"query": "stuff"}}}'],
['term', 'field:stuff', '{"query": {"term": {"field": "stuff"}}}'],
['terms', 'field:stuff1,stuff2', '{"query": {"terms": {"field": ["stuff1", "stuff2"]}}}'],
]
for query in queries:
elasticsearch_engine.query_type = query[0]
params = elasticsearch_engine.request(query[1], self.default_params)
self.assertEqual(loads(params["data"]), loads(query[2]))
def test_basic_failures(self):
queries = [
['match', 'stuff', 'query format must be "key:value'],
['term', 'stuff', 'query format must be key:value'],
['terms', 'stuff', 'query format must be key:value1,value2'],
]
for query in queries:
elasticsearch_engine.query_type = query[0]
with self.assertRaises(ValueError) as context:
elasticsearch_engine.request(query[1], self.default_params)
self.assertIn(query[2], str(context.exception))
def test_custom_queries(self):
queries = [
[
'field:stuff',
'{"query": {"match": {"{{KEY}}": {"query": "{{VALUE}}"}}}}',
'{"query": {"match": {"field": {"query": "stuff"}}}}',
],
[
'stuff',
'{"query": {"simple_query_string": {"query": "{{QUERY}}"}}}',
'{"query": {"simple_query_string": {"query": "stuff"}}}',
],
[
'space stuff',
'{"query": {"simple_query_string": {"query": "{{QUERY}}"}}}',
'{"query": {"simple_query_string": {"query": "space stuff"}}}',
],
[
'"space stuff"',
'{"query": {"simple_query_string": {"query": "{{QUERY}}"}}}',
'{"query": {"simple_query_string": {"query": "\\\"space stuff\\\""}}}',
],
[
"embedded'apostrophe",
'{"query": {"simple_query_string": {"query": "{{QUERY}}"}}}',
'{"query": {"simple_query_string": {"query": "embedded\'apostrophe"}}}',
],
[
'more:stuff',
'{"query": {"simple_query_string": {"query": "{{QUERY}}"}}}',
'{"query": {"simple_query_string": {"query": "more:stuff"}}}',
],
[
'field:stuff',
'{"query": {"term": {"{{KEY}}": "{{VALUE}}"}}}',
'{"query": {"term": {"field": "stuff"}}}',
],
[
'field:more:stuff',
'{"query": {"match": {"{{KEY}}": {"query": "{{VALUE}}"}}}}',
'{"query": {"match": {"field": {"query": "more:stuff"}}}}',
],
[
'field:stuff1,stuff2',
'{"query": {"terms": {"{{KEY}}": "{{VALUES}}"}}}',
'{"query": {"terms": {"field": ["stuff1", "stuff2"]}}}',
],
[
'field:stuff1',
'{"query": {"terms": {"{{KEY}}": "{{VALUES}}"}}}',
'{"query": {"terms": {"field": ["stuff1"]}}}',
],
]
elasticsearch_engine.query_type = 'custom'
for query in queries:
elasticsearch_engine.custom_query_json = query[1]
params = elasticsearch_engine.request(query[0], self.default_params)
self.assertEqual(loads(params["data"]), loads(query[2]))
def test_custom_failures(self):
queries = [
['stuff', '{"query": {"match": {"{{KEY}}": {"query": "{{VALUE}}"}}}}', 'query format must be "key:value"'],
['stuff', '{"query": {"terms": {"{{KEY}}": "{{VALUES}}"}}}', 'query format must be "key:value"'],
['stuff', '{"query": {"simple_query_string": {"query": {{QUERY}}}}}', 'invalid custom_query string'],
['stuff', '"query": {"simple_query_string": {"query": "{{QUERY}}"}}}', 'invalid custom_query string'],
]
elasticsearch_engine.query_type = 'custom'
for query in queries:
elasticsearch_engine.custom_query_json = query[1]
with self.assertRaises(ValueError) as context:
elasticsearch_engine.request(query[0], self.default_params)
self.assertIn(query[2], str(context.exception))
# vi:sw=4