> For the complete documentation index, see [llms.txt](https://docs.threatdefence.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.threatdefence.com/soc-analyst-guide/search-queries.md).

# Search Queries

#### Search Language Queries

TD employs Lucene query for querying alert data. The purpose of Lucene is to provide software developers with an easy-to-use toolkit, facilitating the implementation of full-text search capabilities within target systems or to use this foundation to build a complete full-text search engine.

#### Key Matching

You can specify fields to search in the query syntax:

* where the `status` field contains `active`

  ```
  status:active
  ```
* where the `title` field contains `quick` or `brown`

  ```
  title:(quick OR brown)
  ```
* where the `author` field contains the exact phrase `John Smith`

  ```
  author:"John Smith"
  ```
* where the `first name` field contains `Alice` (note how we need to escape the space with a backslash)

  ```
  first\ name:Alice
  ```
* where any of the fields `book.title`, `book.content`, or `book.date` contains `quick` or `brown` (note how we need to escape the `*` with a backslash):

  ```
  book.\*:(quick OR brown)
  ```
* Search for "foo bar" in the title field and "quick fox" in the body field.

  ```
  title:"foo bar" AND body:"quick fox"
  ```
* Search for either the phrase "foo bar" in the title field AND the phrase "quick fox" in the body field or the word "fox" in the title field.

  ```
  (title:"foo bar" AND body:"quick fox") OR title:fox
  ```
* Search for the word "foo" and not "bar" in the title field

  ```
  title:foo -title:bar
  ```
* where the field `title` has any non-null value:

  ```
  _exists_:title
  ```

#### Wildcard Matching

* Search for any word that starts with "foo" in the title field.

  ```
  title:foo*
  ```
* Search for any word that starts with "foo" and ends with "bar" in the title field.

  ```
  title:foo*bar
  ```
* Note that Lucene doesn't support using a `*` symbol as the first character of a search.

#### Recommend Reading

* [Elastic Query DSL Query String Syntax](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/query-dsl-query-string-query.html#query-string-syntax)
* [Apache Lucene Query Parser Syntax](https://lucene.apache.org/core/2_9_4/queryparsersyntax.html)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.threatdefence.com/soc-analyst-guide/search-queries.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
