Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
62acb91
Implement SPATIAL flag.
flatheadmill Sep 23, 2025
53abe46
Triangle encoding for spatial indexing.
flatheadmill Oct 13, 2025
29ee9db
Implement polygon tessellation.
flatheadmill Oct 13, 2025
77d0c23
Radix selection for block kd-tree partitioning.
flatheadmill Oct 13, 2025
ba6d77c
Add a surveyor to determine spread and prefix.
flatheadmill Oct 16, 2025
32b4e04
Add delta compression for block kd-tree leaf nodes.
flatheadmill Oct 18, 2025
9c6fc52
Implement block kd-tree.
flatheadmill Oct 20, 2025
c8a0904
XOR delta compression for f64 polygon coordinates.
flatheadmill Oct 27, 2025
feef022
Triangulation is not just a conversion.
flatheadmill Oct 27, 2025
b36c3bf
Slot block kd-tree into Tantivy.
flatheadmill Oct 25, 2025
19eab16
Remove `radix_select.rs`.
flatheadmill Nov 4, 2025
1009057
Read block kd-tree nodes using `from_le_bytes`.
flatheadmill Nov 4, 2025
e55ba81
Complete Spatial/Geometry type integration.
flatheadmill Nov 13, 2025
05cf864
Revert "Remove `radix_select.rs`."
flatheadmill Nov 18, 2025
768abcb
Fix `select_nth_unstable_by_key` midpoint duplicates.
flatheadmill Nov 18, 2025
0fa1c4c
bugfix
fulmicoton-dd Dec 1, 2025
973ad35
added doc
fulmicoton-dd Dec 3, 2025
1a3a22a
plastic surgery
fulmicoton-dd Dec 3, 2025
7e22446
Added bugfix and unit tests
fulmicoton-dd Dec 3, 2025
9abc97b
plastic surgery
fulmicoton-dd Dec 3, 2025
e4ecff4
Introduced geopoint.
fulmicoton-dd Dec 3, 2025
4789afc
Introduced geopoint.
fulmicoton-dd Dec 3, 2025
a3f396a
Change naming convention of `ContainsRelation`.
flatheadmill Dec 14, 2025
acad8c0
Remove unnecessary `clone()`.
flatheadmill Dec 14, 2025
021b86a
Adjust for segments with no geo data.
flatheadmill Dec 15, 2025
1b75eb2
Expose Within and Contains in SpatialQuery.
flatheadmill Dec 16, 2025
5411b03
Fix within search.
flatheadmill Dec 23, 2025
22a02fb
Implement index type configuration.
flatheadmill Jan 5, 2026
dac73c0
Remove `order_by_score()`.
flatheadmill Jan 18, 2026
ebf6db8
Bit-packed XOR compression.
flatheadmill Jan 18, 2026
edda52e
Create surfaces.
flatheadmill Jan 23, 2026
967d5c7
Hush some missing doc string warnings.
flatheadmill Jan 27, 2026
1b76d7b
Ingest S2 tractability study.
flatheadmill Jan 28, 2026
4160cff
Index builder.
flatheadmill Jan 29, 2026
2c1136c
Edge serialization and per-document build.
flatheadmill Feb 26, 2026
d0d8b56
Add cell index merge pipeline for segment compaction.
flatheadmill Feb 28, 2026
8d3966b
Decouple EdgeWriter from IndexBuilder.
flatheadmill Mar 2, 2026
22069ba
Add interior ring support to GeometryData.
flatheadmill Mar 4, 2026
717e1fe
Fix three bugs preventing spatial queries from returning results.
flatheadmill Mar 8, 2026
efcf8c1
Fix edge reader forward walk across set boundaries.
flatheadmill Mar 8, 2026
8d99b2a
Fix interior cell shortcut and Subdivided range walk in spatial queries.
flatheadmill Mar 8, 2026
38eddd3
Add vertex verification to intersects interior shortcut.
flatheadmill Mar 8, 2026
99ebdc3
Fix duplicate for_field call in merger edge write and remove dbg.
flatheadmill Mar 8, 2026
1728379
Fix geometry ID alignment in merged edge index.
flatheadmill Mar 9, 2026
dbed049
Add spatial predicates to the query grammar.
flatheadmill Mar 10, 2026
aa390d6
Support points and line strings in the spatial index.
flatheadmill Mar 10, 2026
c96e65e
Normalize GeoJSON hole rings and replace brute_force_contains in the …
flatheadmill Mar 10, 2026
dcf6177
Port S2 edge distance functions from s2edge_distances.cc.
flatheadmill Mar 13, 2026
7f8ed91
Add distance query with $within and $between syntax.
flatheadmill Mar 13, 2026
955a770
Introduce the smash pipeline and route both paths through it.
flatheadmill Mar 16, 2026
c23ebb0
Port edge-pair distance functions from s2edge_distances.cc.
flatheadmill Mar 17, 2026
975b885
Port S2Cell distance functions from s2cell.cc.
flatheadmill Mar 18, 2026
b8ce0e2
Add closest edge query with branch-and-bound traversal.
flatheadmill Mar 20, 2026
acb4915
Route $within and $between through closest_edge_query.
flatheadmill Mar 21, 2026
07fad24
Add spatial query executor for join support.
flatheadmill Mar 21, 2026
d380d12
Add filtered search to closest_edge_query and distance_query. Add exe…
flatheadmill Mar 22, 2026
1650000
Implement PlanNode::Join in the executor.
flatheadmill Mar 23, 2026
02c5d79
Run cargo fmt.
flatheadmill Mar 24, 2026
956ba96
Merge upstream main through tantivy 0.26 release.
flatheadmill Mar 24, 2026
49df855
Remove radix select again.
flatheadmill Mar 24, 2026
0666cbe
Wire all join relations and add filtered search to ContainsQuery.
flatheadmill Mar 24, 2026
407d1fd
Remove distance_query module.
flatheadmill Mar 24, 2026
1d11401
Implement PlanNode::Knn with cross-segment merge.
flatheadmill Mar 25, 2026
19291ff
Implement Clone for PlanNode and SpatialExecutor.
flatheadmill Mar 25, 2026
4aacb0f
Add $query() syntax for spatial joins in the query language.
flatheadmill Mar 26, 2026
7e33be3
Absorb boolean siblings into the spatial join's outer query.
flatheadmill Mar 26, 2026
48b95e9
Rework edge index format to flags byte with forward-only walk.
flatheadmill Mar 26, 2026
aab0311
Run cargo fmt.
flatheadmill Mar 26, 2026
c62d4d4
Comment and doc string tidy.
flatheadmill Mar 26, 2026
667e169
Add planar geometry predicates and robust crate dependency.
flatheadmill Mar 26, 2026
fb58454
Parameterize EdgeWriter and EdgeReader by Surface.
flatheadmill Mar 27, 2026
9abf5ea
Fix multi-field spatial index and point merge panic.
flatheadmill Mar 27, 2026
ba418f8
Preserve ring structure through merge.
flatheadmill Mar 29, 2026
cd30fa2
Split EdgeReader into raw reader and EdgeCache.
flatheadmill Mar 29, 2026
6ddcd59
Replace u32 geometry_id with (u16, u32) tuple.
flatheadmill Mar 29, 2026
b9c299b
Remove GeometryMap from the merge pipeline.
flatheadmill Mar 29, 2026
fcb200a
Rewrite merge pipeline as interleave, collapse, merge.
flatheadmill Mar 31, 2026
b4a76e3
Remove collapse and merge from merger.
flatheadmill Mar 31, 2026
1dec3c1
Track geometry count incrementally on HeapEntry.
flatheadmill Mar 31, 2026
3156f0b
Add interleave metrics.
flatheadmill Apr 1, 2026
40adc6b
Move interior mutability and Rc into EdgeCache.
flatheadmill Apr 1, 2026
5b4f19b
Remove dead code.
flatheadmill Apr 1, 2026
afc6db0
Rename geometry_id field.
flatheadmill Apr 1, 2026
903550b
Count crossings in interleave.
flatheadmill Apr 1, 2026
393d095
Run cargo fmt.
flatheadmill Apr 1, 2026
9d4806b
Remove needless borrow on edge_cache in flatten calls.
flatheadmill Apr 1, 2026
d3e0f7f
Cache v0 and v1 on CoarseEdge.
flatheadmill Apr 1, 2026
3b55999
Keep a running total for SpatialWriter::mem_usage.
meyburgh Oct 8, 2026
ec8da16
Read an empty cell index as empty in CellIndexReader::open.
meyburgh Oct 8, 2026
8aeafca
Order the geo_json example's TopDocs by score.
meyburgh Oct 8, 2026
c381f6a
Count spatial writer memory exactly and reject corrupt spatial indexes.
meyburgh Oct 9, 2026
9fa0c4b
Fix spatial distance, kNN, contains and space usage bugs.
meyburgh Oct 9, 2026
f0b4c91
Fix spatial query, join, format and performance bugs.
meyburgh Oct 9, 2026
4dbfa75
Fix clippy warnings in S1ChordAngle and S2CellId.
meyburgh Oct 9, 2026
fc8a4e5
Fix spatial boundaries, union containment and append scaling.
meyburgh Oct 9, 2026
81e996d
Make spatial geometry valid, fix contact and containment, and harden …
meyburgh Oct 10, 2026
0fbb9e6
Merge upstream main and port spatial fields onto the segment plugin s…
meyburgh Oct 10, 2026
0c573b7
Add latitude-longitude rectangle queries, and decide points without d…
meyburgh Oct 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ datasketches = { version = "0.5.0", features = ["hll"] }
futures-util = { version = "0.3.28", optional = true }
futures-channel = { version = "0.3.28", optional = true }
fnv = "1.0.7"
num-bigint = "0.4"
num-rational = "0.4"
num-traits = "0.2"
robust = "1"
typetag = "0.2.21"
unwrap-infallible = "1.0.0"
serde-tuple-vec-map = "1.0.1"
Expand Down
51 changes: 51 additions & 0 deletions examples/geo_json.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use tantivy::collector::TopDocs;
use tantivy::query::SpatialQuery;
use tantivy::schema::{Schema, Value, SPATIAL, STORED, TEXT};
use tantivy::{Index, IndexWriter, TantivyDocument};
fn main() -> tantivy::Result<()> {
let mut schema_builder = Schema::builder();
schema_builder.add_json_field("properties", STORED | TEXT);
schema_builder.add_spatial_field("geometry", STORED | SPATIAL);
let schema = schema_builder.build();
let index = Index::create_in_ram(schema.clone());
let mut index_writer: IndexWriter = index.writer(50_000_000)?;
let doc = TantivyDocument::parse_json(
&schema,
r#"{
"type":"Feature",
"geometry":{
"type":"Polygon",
"coordinates":[[[-99.483911,45.577697],[-99.483869,45.571457],[-99.481739,45.571461],[-99.474881,45.571584],[-99.473167,45.571615],[-99.463394,45.57168],[-99.463391,45.57883],[-99.463368,45.586076],[-99.48177,45.585926],[-99.48384,45.585953],[-99.483885,45.57873],[-99.483911,45.577697]]]
},
"properties":{
"admin_level":"8",
"border_type":"city",
"boundary":"administrative",
"gnis:feature_id":"1267426",
"name":"Hosmer",
"place":"city",
"source":"TIGER/Line® 2008 Place Shapefiles (http://www.census.gov/geo/www/tiger/)",
"wikidata":"Q2442118",
"wikipedia":"en:Hosmer, South Dakota"
}
}"#,
)?;
index_writer.add_document(doc)?;
index_writer.commit()?;

let reader = index.reader()?;
let searcher = reader.searcher();
let field = schema.get_field("geometry").unwrap();
let query = SpatialQuery::from_bounds(field, [[-99.49, 45.56], [-99.45, 45.59]]);
let hits = searcher.search(&query, &TopDocs::with_limit(10).order_by_score())?;
for (_score, doc_address) in &hits {
let retrieved_doc: TantivyDocument = searcher.doc(*doc_address)?;
if let Some(field_value) = retrieved_doc.get_first(field) {
if let Some(geometry_box) = field_value.as_value().into_geometry() {
println!("Retrieved geometry: {:?}", geometry_box);
}
}
}
assert_eq!(hits.len(), 1);
Ok(())
}
2 changes: 1 addition & 1 deletion query-grammar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ edition = "2024"
nom = "7"
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
ordered-float = "5.0.0"
ordered-float = { version = "5.0.0", features = ["serde"] }
fnv = "1.0.7"
48 changes: 47 additions & 1 deletion query-grammar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub use crate::infallible::LenientError;
pub use crate::occur::Occur;
use crate::query_grammar::{parse_to_ast, parse_to_ast_lenient};
pub use crate::user_input_ast::{
Delimiter, UserInputAst, UserInputBound, UserInputLeaf, UserInputLiteral,
Delimiter, SpatialPredicateKind, UserInputAst, UserInputBound, UserInputLeaf, UserInputLiteral,
};

#[derive(Debug, Serialize)]
Expand Down Expand Up @@ -58,6 +58,52 @@ mod tests {
assert!(parse_query("title:").is_err());
}

#[test]
fn test_spatial_intersects() {
// Test simple case first.
let ast = parse_query(r#"geo:$intersects(1.0 2.0, 3.0 4.0, 5.0 6.0)"#).unwrap();
let debug = format!("{ast:?}");
assert!(debug.contains("$intersects"), "got: {debug}");
}

#[test]
fn test_spatial_contains() {
let ast = parse_query(r#"geo:$contains(1.0 2.0, 3.0 4.0, 5.0 6.0)"#).unwrap();
let debug = format!("{ast:?}");
assert!(debug.contains("$contains"), "got: {debug}");
}

#[test]
fn test_spatial_join_debug() {
for (query, expected) in [
(
"geo:$within(1rad, $query(name:point))",
"\"geo\":$within(1rad, $query(name:point))",
),
(
"geo:$between(1rad, 2rad, $query(a))",
"\"geo\":$between(1rad, 2rad, $query(a))",
),
(
"geo:$intersects($query(name:x))",
"\"geo\":$intersects($query(name:x))",
),
(
"geo:$contains($query(name:x))",
"\"geo\":$contains($query(name:x))",
),
("geo:$knn(3, 1 2)", "\"geo\":$knn(3, 1 2)"),
] {
let debug = format!("{:?}", parse_query(query).unwrap());
assert!(debug.contains(expected), "{query} gives {debug}");
}
}

#[test]
fn test_spatial_too_few_coords() {
assert!(parse_query(r#"geo:$intersects(1.0 2.0, 3.0 4.0)"#).is_err());
}

#[test]
fn test_parse_query_lenient_wrong_query() {
let (_, errors) = parse_query_lenient("title:");
Expand Down
Loading