# full text search example

```js
import React from 'react';

import { Link } from 'gatsby'

export default class SearchBar extends React.Component {
  state = {
    query: '',
    results: [],
  }

  render() {
    return (
      <div className={this.props.classNames+" search__parent__div flex-md"}>
        <input className='search__input' type='text' value={this.state.query} onChange={this.search} placeholder={'Search'} aria-label="Search" />
        { // Results list
        (this.state.results.length > 0) && ( // Only show when there are results
        <div className='search__list'>
            <span>Search results</span>
            <ul>
              {this.state.results.map((page) => (
              <li key={page.url}>
                <Link className='search__list_white search__list_non-decoration'
                  to={page.url}>
                  {page.title}
                </Link>
              </li>
              ))}
            </ul>
        </div>
        ) }
      </div>
    )
  }

  getSearchResults(query) {
    if (!query || !window.__LUNR__) return []
    const lunrIndex =  window.__LUNR__[this.props.lng];
    const results = lunrIndex.index.search(query) // you can  customize your search , see https://lunrjs.com/guides/searching.html
    return results.map(({ ref }) => lunrIndex.store[ref])
  }

  search = event => {
    const query = event.target.value
    const results = this.getSearchResults(query)
    this.setState({ results, query })
  }
}
```


---

# Agent Instructions: 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:

```
GET https://bryan-guner.gitbook.io/my-docs/blog-notes/full-text-search-example.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
