> For the complete documentation index, see [llms.txt](https://docs.suggestic.com/graphql/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.suggestic.com/graphql/query/search/food-search-for-food-log/legacy/autocomplete.md).

# Autocomplete

{% hint style="warning" %}
Please refer to the[ Food Search](/graphql/query/search/food-search-for-food-log/food-search.md) section for a new and improved way for searching for foods for food logging or other purposes.
{% endhint %}

The `Autocomplete` search covers all object types (recipes, products, own recipes) and is mostly used for [Food Logging](/graphql/query/queries/food-log.md) purposes.

### Required Arguments

| Argument   | Required | Type                                                                                         | Description                              |
| ---------- | -------- | -------------------------------------------------------------------------------------------- | ---------------------------------------- |
| `query`    | true     | String                                                                                       | Search query                             |
| `mealType` | true     | [MealType](https://docs.suggestic.com/graphql/objects/food-logs/meal-type#available-options) | Type of meal/food that is being searched |

Leaving the `mealType` argument empty will result in a search that covers: RECIPE and USDA\_MEAL. Using the argument will narrow the search to that particular domain.&#x20;

### Available Fields

| Field Name | Type    | Description                                                                                                                      |
| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `enter`    | Boolean | **True** to complete the value based on which the user entered. If this value is not defined, by default it will be set as true. |
| `first`    | String  | Retrieves the first results from the list.                                                                                       |
| `after`    | String  | For more information, refer to the [Search ](https://docs.suggestic.com/graphql/query/search)documentation                       |
| `last`     | String  | Retrieves the last results from the list                                                                                         |

### Pagination

Autocomplete query supports the use of pagination. The following fields can be used

{% tabs %}
{% tab title="Query" %}

```graphql
cursor
    }
     pageInfo {
      endCursor
      hasNextPage
    }
```

{% endtab %}
{% endtabs %}

Refer to the [pagination ](https://docs.suggestic.com/graphql/query/search#pagination)documentation for more information.

### Examples

Searching in a single *meal type*

{% tabs %}
{% tab title="Query" %}

```graphql
{
  autocomplete(query: "egg" mealType: USDA_MEAL) {
    edges {
      node {
        mealType
        databaseId
        name
      }
    }
  }
}

```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "autocomplete": {
      "edges": [
        {
          "node": {
            "mealType": "USDA_MEAL",
            "databaseId": "01123",
            "name": "Egg, whole, raw, fresh"
          }
        },
        {
          "node": {
            "mealType": "USDA_MEAL",
            "databaseId": "01124",
            "name": "Egg, white, raw, fresh"
          }
        },
        {
          "node": {
            "mealType": "USDA_MEAL",
            "databaseId": "01057",
            "name": "Eggnog"
          }
        },
        {
          "node": {
            "mealType": "USDA_MEAL",
            "databaseId": "11209",
            "name": "Eggplant, raw"
          }
        }
      ]
    }
  }
}
```

{% endtab %}
{% endtabs %}


---

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

```
GET https://docs.suggestic.com/graphql/query/search/food-search-for-food-log/legacy/autocomplete.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.
