validate_index

View as MarkdownOpen in Claude

Validate an existing .swsearch index file, checking schema integrity and returning summary statistics. Use this to verify that an index was built correctly before deploying it.

Parameters

index_file
strRequired

Path to the .swsearch file to validate.

Returns

dict[str, Any] — A dictionary with:

  • valid (bool) — whether the index is valid
  • error (str) — error message if invalid
  • chunk_count (int) — number of chunks (if valid)
  • file_count (int) — number of source files (if valid)
  • config (dict) — index configuration (if valid)

Example

1from signalwire.search import IndexBuilder
2
3builder = IndexBuilder()
4result = builder.validate_index("knowledge.swsearch")
5
6if result["valid"]:
7 print(f"Index OK: {result['chunk_count']} chunks, {result['file_count']} files")
8else:
9 print(f"Invalid index: {result['error']}")