Boolean search (and / or / not)
shamela_search_booleanبحث منطقي (و/أو/دون)
Boolean search the AND-only regular search lacks — combines OR (any_of) and NOT (none_of) with AND (all_of). all_of: terms that must ALL appear (intersection). any_of: at least ONE must appear (union), intersected with all_of. none_of: pages containing ANY of these are excluded. At least one of all_of/any_of is required. The whole expression is ONE Lucene BooleanQuery evaluated over the entire index — all_of as MUST, any_of as SHOULD-min-1, none_of as MUST_NOT — so total_hits is an exact count and the exclusion is exhaustive, not a sample. scope is still worth passing for speed on a large library, not for correctness. If a term has no entry in the index at all it is named in zero_hit_terms: a zero then means that word is not in the library as spelled, which is different from the expression having no match. Examples: shamela_search_boolean({all_of:['الوقف'], any_of:['المسجد','المقبرة'], none_of:['البيع'], scope:{category_ids:[17]}}).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of results to return (1-100, default 20). | |
| scope | No | Restrict to books/authors/categories/period. Recommended: an unscoped boolean search over a large library is exhaustive but slow. Use shamela_list_categories / shamela_resolve to find IDs. | |
| all_of | No | AND — terms that must ALL appear on the page (each term is itself AND-searched, so a multi-word term must co-occur). Intersection of every term's hit set. Leave empty to rely on any_of. | |
| any_of | No | OR — at least ONE of these terms must appear on the page. Union of every term's hit set, then intersected with the all_of result. Leave empty to rely on all_of. | |
| offset | No | Number of results to skip for pagination. Use with `limit` to page through large result sets. The response includes `has_more` and `next_offset` to drive paging. | |
| none_of | No | NOT — pages containing ANY of these terms are excluded, across the whole index (a MUST_NOT clause, not a subtraction inside a sampled window). Optional. | |
| search_in | No | Which page sections each sub-search looks in: body (matn), foot (footnotes), comment. Default ['body','foot']. | |
| response_format | No | Output format for the human-readable text. 'markdown' (default) is best for direct display; 'json' returns the same data as a single JSON code block; 'none' skips the rendered text entirely and returns a one-line pointer, leaving `structuredContent` as the whole answer. The structured data is returned in `structuredContent` regardless of this setting, so a caller that parses it should pass 'none' — the character budget is measured over BOTH channels, and the unread copy is otherwise spending most of it. Requires the 'response_format.none' capability (see shamela_brief). | markdown |