Skip to main content

Full-Text Search Queries

This page demonstrates how to perform text searches and combine them with graph queries.

Search for recipes containing "chocolate":


{
"@context": {
"f": "https://ns.flur.ee/ledger#",
"schema": "http://schema.org/",
"recipe": "https://recipe-example.com/ns/"
},
"select": {
"?recipe": ["schema:name", "schema:description"]
},
"where": [
{ "@id": "?recipe", "@type": "recipe:Recipe" },
{ "@id": "?recipe", "f:fullText": "chocolate" }
]
}

This searches all indexed text fields for "chocolate" and returns matching recipes.

Search with Relevance Scores

Get relevance scores to understand why results ranked:


{
"@context": {
"f": "https://ns.flur.ee/ledger#",
"schema": "http://schema.org/",
"recipe": "https://recipe-example.com/ns/"
},
"select": ["?name", "?score"],
"where": [
{ "@id": "?recipe", "@type": "recipe:Recipe", "schema:name": "?name" },
{ "@id": "?recipe", "f:fullText": "?search" },
{ "@id": "?search", "f:query": "pasta", "f:score": "?score" }
],
"orderBy": [{"desc": "?score"}]
}

Higher scores indicate better matches.

Search Specific Fields

Search only in the ingredients field:


{
"@context": {
"f": "https://ns.flur.ee/ledger#",
"schema": "http://schema.org/",
"recipe": "https://recipe-example.com/ns/"
},
"select": {
"?recipe": ["schema:name", "recipe:ingredients"]
},
"where": [
{ "@id": "?recipe", "@type": "recipe:Recipe", "recipe:ingredients": "?ingredients" },
{ "@id": "?ingredients", "f:fullText": "garlic" }
]
}

This finds recipes where "garlic" appears in the ingredients.

Search for multiple terms:


{
"@context": {
"f": "https://ns.flur.ee/ledger#",
"schema": "http://schema.org/",
"recipe": "https://recipe-example.com/ns/"
},
"select": {
"?recipe": ["schema:name"]
},
"where": [
{ "@id": "?recipe", "@type": "recipe:Recipe" },
{ "@id": "?recipe", "f:fullText": "creamy cheese" }
]
}

Recipes containing both "creamy" and "cheese" will rank highest.

Combine Search with Graph Filters

Find vegan recipes mentioning "tofu":


{
"@context": {
"f": "https://ns.flur.ee/ledger#",
"schema": "http://schema.org/",
"recipe": "https://recipe-example.com/ns/"
},
"select": {
"?recipe": ["schema:name", "schema:description"]
},
"where": [
{ "@id": "?recipe", "@type": "recipe:Recipe", "recipe:dietaryRestrictions": {"@id": "recipe:diets/vegan"} },
{ "@id": "?recipe", "f:fullText": "tofu" }
]
}

This uses both:

  • Graph filter: recipe:dietaryRestrictions = vegan
  • Text search: contains "tofu"

Search by Cuisine

Find Italian recipes with "tomato":


{
"@context": {
"f": "https://ns.flur.ee/ledger#",
"schema": "http://schema.org/",
"recipe": "https://recipe-example.com/ns/"
},
"select": {
"?recipe": ["schema:name", "recipe:cuisine"]
},
"where": [
{ "@id": "?recipe", "@type": "recipe:Recipe", "recipe:cuisine": {"@id": "recipe:cuisines/italian"} },
{ "@id": "?recipe", "f:fullText": "tomato" }
]
}

Stemming Effects

Fluree's text search includes stemming—word variations are matched:


{
"where": { "@id": "?recipe", "f:fullText": "baking" }
}

This matches:

  • "bake"
  • "baked"
  • "baking"
  • "baker"
info

Stemming helps users find results even if they don't use the exact word form in the document.

Quick Recipe Finder

Find recipes under 30 minutes prep that contain specific ingredients:


{
"@context": {
"f": "https://ns.flur.ee/ledger#",
"schema": "http://schema.org/",
"recipe": "https://recipe-example.com/ns/"
},
"select": {
"?recipe": ["schema:name", "recipe:prepTime", "recipe:cookTime"]
},
"where": [
{ "@id": "?recipe", "@type": "recipe:Recipe", "recipe:prepTime": "?prep" },
["filter", "(< ?prep 30)"],
{ "@id": "?recipe", "f:fullText": "avocado lime" }
]
}

Find gluten-free recipes with specific ingredients:


{
"@context": {
"f": "https://ns.flur.ee/ledger#",
"schema": "http://schema.org/",
"recipe": "https://recipe-example.com/ns/"
},
"select": {
"?recipe": ["schema:name"],
"?diet": []
},
"where": [
{ "@id": "?recipe", "@type": "recipe:Recipe", "recipe:dietaryRestrictions": "?restriction" },
{ "@id": "?restriction", "schema:name": "?diet" },
{ "@id": "?recipe", "f:fullText": "noodles" }
]
}

Find Chef Lee's recipes that mention "soy sauce":


{
"@context": {
"f": "https://ns.flur.ee/ledger#",
"schema": "http://schema.org/",
"recipe": "https://recipe-example.com/ns/"
},
"select": {
"?recipe": ["schema:name", "recipe:instructions"]
},
"where": [
{ "@id": "?recipe", "@type": "recipe:Recipe", "recipe:author": {"@id": "recipe:authors/chef-lee"} },
{ "@id": "?recipe", "f:fullText": "soy sauce" }
]
}

Negative Search (Exclude Terms)

Find chocolate recipes that don't mention "nuts":


{
"@context": {
"f": "https://ns.flur.ee/ledger#",
"schema": "http://schema.org/",
"recipe": "https://recipe-example.com/ns/"
},
"select": {
"?recipe": ["schema:name"]
},
"where": [
{ "@id": "?recipe", "@type": "recipe:Recipe" },
{ "@id": "?recipe", "f:fullText": "chocolate" },
{
"minus": { "@id": "?recipe", "f:fullText": "nuts" }
}
]
}

Summary

Full-text search patterns:

PatternUse Case
Basic searchFind documents containing term
Field-specificSearch only ingredients, description, etc.
Multi-termDocuments with multiple terms rank higher
With graph filtersCombine text + relationship constraints
StemmingMatch word variations automatically
Negative searchExclude documents with certain terms
Relevance scoresUnderstand ranking factors

Full-text search transforms Fluree from a graph database into a searchable knowledge base—perfect for applications that need both structured queries and freeform search.