> For the complete documentation index, see [llms.txt](https://guides.ia.numerique.gouv.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guides.ia.numerique.gouv.fr/albert-api/api-reference/liste-des-endpoint/search.md).

# Search

## Search

> Get relevant chunks from the collections and a query.

```json
{"openapi":"3.1.0","info":{"title":"Albert API","version":"0.4.9"},"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}},"schemas":{"CreateSearch":{"properties":{"collection_ids":{"items":{"type":"integer","exclusiveMinimum":0},"type":"array","maxItems":100,"minItems":0,"title":"Collection Ids","description":"List of collections ID.","default":[]},"document_ids":{"items":{"type":"integer","exclusiveMinimum":0},"type":"array","maxItems":100,"minItems":0,"title":"Document Ids","description":"List of document IDs","default":[]},"metadata_filters":{"anyOf":[{"$ref":"#/components/schemas/ComparisonFilter"},{"$ref":"#/components/schemas/CompoundFilter"},{"type":"null"}],"title":"Metadata Filters","description":"Metadata filters to apply to the search."},"limit":{"type":"integer","maximum":100,"exclusiveMinimum":0,"title":"Limit","description":"Number of results to return.","default":10},"offset":{"type":"integer","minimum":0,"title":"Offset","description":"Offset for pagination, specifying how many results to skip from the beginning.","default":0},"method":{"$ref":"#/components/schemas/SearchMethod","description":"Search method to use.","default":"semantic"},"rff_k":{"type":"integer","maximum":16384,"minimum":0,"title":"Rff K","description":"Smoothing constant for Reciprocal Rank Fusion (RRF) algorithm in hybrid search (recommended: from 10 to 100).","default":60},"score_threshold":{"type":"number","maximum":1,"minimum":0,"title":"Score Threshold","description":"Score of cosine similarity threshold for filtering results, only available for semantic search method.","default":0},"query":{"anyOf":[{"type":"string","minLength":1},{"type":"null"}],"title":"Query","description":"Query related to the search."}},"additionalProperties":true,"type":"object","title":"CreateSearch"},"ComparisonFilter":{"properties":{"key":{"type":"string","maxLength":255,"minLength":1,"title":"Key"},"type":{"$ref":"#/components/schemas/ComparisonFilterType"},"value":{"anyOf":[{"type":"string","maxLength":255,"minLength":1},{"type":"integer","maximum":10000000000000000,"minimum":-10000000000000000},{"type":"number","maximum":10000000000000000,"minimum":-10000000000000000},{"type":"boolean"}],"title":"Value"}},"additionalProperties":true,"type":"object","required":["key","type","value"],"title":"ComparisonFilter"},"ComparisonFilterType":{"type":"string","enum":["eq","sw","ew","co"],"title":"ComparisonFilterType","description":"Comparison filter type for metadata filters."},"CompoundFilter":{"properties":{"filters":{"items":{"$ref":"#/components/schemas/ComparisonFilter"},"type":"array","maxItems":4,"minItems":2,"title":"Filters","description":"List of filters to apply to the search."},"operator":{"$ref":"#/components/schemas/CompoundFilterOperator","description":"Operator to use for the compound filter."}},"additionalProperties":true,"type":"object","required":["filters","operator"],"title":"CompoundFilter"},"CompoundFilterOperator":{"type":"string","enum":["and","or"],"title":"CompoundFilterOperator","description":"Compound filter operator for metadata filters."},"SearchMethod":{"type":"string","enum":["hybrid","semantic","lexical"],"title":"SearchMethod"},"Searches":{"properties":{"object":{"type":"string","const":"list","title":"Object","description":"The type of the object.","default":"list"},"data":{"items":{"$ref":"#/components/schemas/Search"},"type":"array","title":"Data","description":"List of search results."},"usage":{"$ref":"#/components/schemas/api__schemas__usage__Usage","description":"Usage information for the request."}},"additionalProperties":true,"type":"object","required":["data"],"title":"Searches"},"Search":{"properties":{"method":{"$ref":"#/components/schemas/SearchMethod","description":"Search method used."},"score":{"type":"number","title":"Score","description":"Score of the search result."},"chunk":{"$ref":"#/components/schemas/Chunk","description":"Chunk of the search result."}},"additionalProperties":true,"type":"object","required":["method","score","chunk"],"title":"Search"},"Chunk":{"properties":{"object":{"type":"string","const":"chunk","title":"Object","description":"The type of the object.","default":"chunk"},"id":{"type":"integer","minimum":0,"title":"Id","description":"The ID of the chunk."},"collection_id":{"type":"integer","minimum":0,"title":"Collection Id","description":"The ID of the collection the chunk belongs to."},"document_id":{"type":"integer","minimum":0,"title":"Document Id","description":"The ID of the document the chunk belongs to."},"content":{"type":"string","minLength":1,"title":"Content","description":"The content of the chunk."},"metadata":{"anyOf":[{"additionalProperties":{"anyOf":[{"type":"string","maxLength":255,"minLength":1},{"type":"integer","maximum":10000000000000000,"minimum":-10000000000000000},{"type":"number","maximum":10000000000000000,"minimum":-10000000000000000},{"type":"boolean"}]},"propertyNames":{"maxLength":255,"minLength":1},"type":"object","maxProperties":10,"minProperties":1,"description":"Extra metadata for the source"},{"type":"null"}],"title":"Metadata","description":"Metadata of the chunk"},"created":{"type":"integer","title":"Created","description":"The date of the chunk creation."}},"additionalProperties":true,"type":"object","required":["id","collection_id","document_id","content"],"title":"Chunk"},"api__schemas__usage__Usage":{"properties":{"prompt_tokens":{"type":"integer","title":"Prompt Tokens","description":"Number of prompt tokens (e.g. input tokens).","default":0},"completion_tokens":{"type":"integer","title":"Completion Tokens","description":"Number of completion tokens (e.g. output tokens).","default":0},"total_tokens":{"type":"integer","title":"Total Tokens","description":"Total number of tokens (e.g. input and output tokens).","default":0},"cost":{"type":"number","title":"Cost","description":"Total cost of the request.","default":0},"carbon":{"$ref":"#/components/schemas/CarbonFootprintUsage","deprecated":true},"impacts":{"$ref":"#/components/schemas/api__schemas__usage__EnvironmentalImpacts"},"requests":{"type":"integer","title":"Requests","description":"Number of model requests.","default":0}},"additionalProperties":true,"type":"object","title":"Usage"},"CarbonFootprintUsage":{"properties":{"kWh":{"$ref":"#/components/schemas/CarbonFootprintUsageKWh","deprecated":true},"kgCO2eq":{"$ref":"#/components/schemas/CarbonFootprintUsageKgCO2eq","deprecated":true}},"additionalProperties":true,"type":"object","title":"CarbonFootprintUsage"},"CarbonFootprintUsageKWh":{"properties":{"min":{"type":"number","title":"Min","description":"Minimum carbon footprint in kWh.","default":0,"deprecated":true},"max":{"type":"number","title":"Max","description":"Maximum carbon footprint in kWh.","default":0,"deprecated":true}},"additionalProperties":true,"type":"object","title":"CarbonFootprintUsageKWh"},"CarbonFootprintUsageKgCO2eq":{"properties":{"min":{"type":"number","title":"Min","description":"Minimum carbon footprint in kgCO2eq (global warming potential).","default":0,"deprecated":true},"max":{"type":"number","title":"Max","description":"Maximum carbon footprint in kgCO2eq (global warming potential).","default":0,"deprecated":true}},"additionalProperties":true,"type":"object","title":"CarbonFootprintUsageKgCO2eq"},"api__schemas__usage__EnvironmentalImpacts":{"properties":{"kWh":{"type":"number","title":"Kwh","description":"Carbon footprint in kWh.","default":0},"kgCO2eq":{"type":"number","title":"Kgco2Eq","description":"Carbon footprint in kgCO2eq (global warming potential).","default":0}},"additionalProperties":true,"type":"object","title":"EnvironmentalImpacts"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/search":{"post":{"tags":["Search"],"summary":"Search","description":"Get relevant chunks from the collections and a query.","operationId":"search_v1_search_post","parameters":[{"name":"required","in":"query","required":false,"schema":{"type":"boolean","default":true,"title":"Required"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSearch"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Searches"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```


---

# 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://guides.ia.numerique.gouv.fr/albert-api/api-reference/liste-des-endpoint/search.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.
