Skip to main content

Elasticsearch Query Assistant

The Elasticsearch Query Assistant lets you search with a query written in Elasticsearch's own query language, instead of words in the search bar. Use it when a search needs more than the search bar offers, for example documents that mention one word but not another, or documents of one type created in a particular year.

You do not need to know the query language to use it. Describe what you are looking for to the Query Assistant, and it writes the query for you. Before you run it:

  • Check the query does what you asked. The assistant explains the query it wrote. Read the explanation, and change your request if it is not what you meant.
  • Check the count under the query. It shows how many documents the query finds before you run it, so you can tell at once if it finds none, or far too many.

Like Search, a query only finds documents you have access to.

What you can do in the Elasticsearch Query Assistant​

  • Ask the Query Assistant to write a query from a request in your own words
  • Go back to an earlier conversation with the assistant
  • Write or change a query yourself in the query editor
  • See how many documents a query finds before you run it
  • Run the query and work with the results as you would in Search
  • Preview a result, and go back to the search bar

Raw query mode​

To open the Elasticsearch Query Assistant, open Search and click the code icon in the search bar (Switch to raw Elasticsearch query mode). The page changes to three panels.

Raw query mode with the Query Assistant on the left, the query editor in the middle and the results on the right
Raw query mode
PanelWhat it is for
Query Assistant (left)Ask for a query in your own words. Your earlier conversations are listed beside it.
Elasticsearch Query (JSON) (middle)The query that runs, with the buttons that run it, clear it, and go back to the search bar.
Results (right)The documents the query found.

Query Assistant​

Type what you are looking for in the prompt and press Enter. The assistant writes a query, puts it in the query editor, and explains in its answer what the query finds. If the query is not what you meant, reply in the same chat to change it. The assistant also works from any change you made to the query yourself.

A request in the Query Assistant, the query it wrote in the editor, and the two documents the query found
A query written by the Query Assistant
ControlWhat it does
New chatStarts an empty conversation.
Chat list (under New chat)Lists your earlier conversations, each named after your request. Click one to open it again.
ModelThe AI model that writes the query. Docwize remembers your choice in this browser.
Ask about ES queries…Where you type your request. Press Enter to send it, or Shift+Enter to start a new line.
Send (arrow)Sends your request, in the same way as Enter.
Paste an image from clipboardPaste an image into the prompt to show the assistant what you mean, for example a screenshot of a form. The image is shown above the prompt until you send it or remove it.

Elasticsearch Query (JSON)​

The editor holds the query that Search runs. The assistant writes its queries here, and you can type or paste a query of your own. When you open raw query mode, the editor holds a query that finds all documents.

A query for the word Quillmarsh in the editor, the count 2 docs under it, and the two documents in the results
A query, its count and its results
ControlWhat it does
Count (under the editor)Shows how many documents the query finds, for example 2 docs. It updates as you change the query.
SearchRuns the query and lists the documents in the results panel.
ClearEmpties the editor.
Simple SearchGoes back to the search bar.

When a query cannot be read​

A query must be valid JSON. If a bracket, comma or quotation mark is missing, the count is replaced by a message saying what Docwize expected and where, and Search is unavailable until you correct it.

The query editor with a missing bracket, and the message saying what was expected and where
A query that is not valid JSON

Results​

The results panel lists the documents the query found, in the same grid as Search. You can sort, filter, export and assign them in the same way. See Search for the results grid.

Click a result's preview icon to read the document. Click the X at the top left of the preview to close it and go back to the results.

A document found by the query, open in the preview
A result in the preview

How to build a query with the Query Assistant​

StepDescription
1Open Search and click the code icon in the search bar.
2Click New chat.
3Type what you are looking for in Ask about ES queries…, for example Find documents whose content mentions Quillmarsh, and press Enter.
4Read the assistant's answer and the count under the query. If the query is not what you meant, reply in the same chat to change it.
5Click Search. The documents are listed in the results panel.

Example: Building a query with the Query Assistant and running it

How to write a query yourself​

StepDescription
1Open Search and click the code icon in the search bar.
2Click in the Elasticsearch Query (JSON) editor and type or paste your query. To start again, click Clear.
3Check the count under the editor. If a message is shown instead, correct the JSON.
4Click Search.

How to go back to an earlier query​

StepDescription
1In the chat list under New chat, click the conversation.
2Read the conversation, and reply to change the query if you need to.
3Click Search to run the query in the editor.
StepDescription
1Click Simple Search. The results of your last query stay on the page.
2Click the back arrow at the left of the results toolbar. The Content Search bar is shown again.