Feat: Add metadata filtering function for /api/v1/retrieval (#9877)

-Added the metadata_dedition parameter in the document retrieval
interface to filter document metadata -Updated the API documentation and
added explanations for the metadata_dedition parameter

### What problem does this PR solve?

Make /api/v1/retrieval api also can use metadata filter

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
天海蒼灆
2025-09-05 11:12:15 +08:00
committed by GitHub
parent 8e30a75e5c
commit 677c99b090
4 changed files with 22 additions and 12 deletions

View File

@ -921,7 +921,7 @@ chunk.update({"content":"sdfx..."})
### Retrieve chunks
```python
RAGFlow.retrieve(question:str="", dataset_ids:list[str]=None, document_ids=list[str]=None, page:int=1, page_size:int=30, similarity_threshold:float=0.2, vector_similarity_weight:float=0.3, top_k:int=1024,rerank_id:str=None,keyword:bool=False,highlight:bool=False) -> list[Chunk]
RAGFlow.retrieve(question:str="", dataset_ids:list[str]=None, document_ids=list[str]=None, page:int=1, page_size:int=30, similarity_threshold:float=0.2, vector_similarity_weight:float=0.3, top_k:int=1024,rerank_id:str=None,keyword:bool=False,cross_languages:list[str]=None,metadata_condition: dict=None) -> list[Chunk]
```
Retrieves chunks from specified datasets.
@ -971,17 +971,14 @@ Indicates whether to enable keyword-based matching:
- `True`: Enable keyword-based matching.
- `False`: Disable keyword-based matching (default).
##### highlight: `bool`
Specifies whether to enable highlighting of matched terms in the results:
- `True`: Enable highlighting of matched terms.
- `False`: Disable highlighting of matched terms (default).
##### cross_languages: `list[string]`
The languages that should be translated into, in order to achieve keywords retrievals in different languages.
##### metadata_condition: `dict`
filter condition for meta_fields
#### Returns
- Success: A list of `Chunk` objects representing the document chunks.