Skip to content

Commit

Permalink
Merge pull request #2 from Sh1nku/facets
Browse files Browse the repository at this point in the history
v0.3.0: Add Faceting with Json facets and facet counts
  • Loading branch information
Sh1nku authored Aug 21, 2023
2 parents 6f4d8e6 + 989dcfe commit 47e73a3
Show file tree
Hide file tree
Showing 80 changed files with 4,575 additions and 2,171 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/count_loc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ name: Count lines of code for the project, and upload to the badge store

on:
push:
branches:
- 'master'
tags:
- '*'
workflow_dispatch:

jobs:
count-loc-and-upload:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.3.0
* Add Facet sets
* Add Json facets
* Be more permissive with arguments to builders, using `Into<Option>`, `Into<String` and `IntoIterator` where appropriate
* Rename builders removing `Builder` suffix

# v0.2.0
* Add query parsers (lucene, dismax, edismax)

Expand Down
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Use the [Rust documentation](https://docs.rs/solrstice) or the [Python documenta
* Select Documents
* Grouping Component Query
* DefTypes (lucene, dismax, edismax)
* Facet Counts (Query, Field, Pivot)
* Json Facet (Query, Stat, Terms, Nested)
* Indexing Documents
* Deleting Documents
## Examples
Expand All @@ -25,8 +27,8 @@ use solrstice::hosts::solr_server_host::SolrSingleServerHost;
use solrstice::models::auth::SolrBasicAuth;
use solrstice::models::context::SolrServerContextBuilder;
use solrstice::models::error::SolrError;
use solrstice::queries::index::{DeleteQueryBuilder, UpdateQueryBuilder};
use solrstice::queries::select::SelectQueryBuilder;
use solrstice::queries::index::{DeleteQuery, UpdateQuery};
use solrstice::queries::select::SelectQuery;
use std::path::Path;

#[derive(Serialize, Deserialize, Debug)]
Expand Down Expand Up @@ -58,7 +60,7 @@ pub async fn example() -> Result<(), SolrError> {
}];
client
.index(
&UpdateQueryBuilder::new(),
&UpdateQuery::new(),
"example_collection",
docs.as_slice(),
)
Expand All @@ -67,18 +69,18 @@ pub async fn example() -> Result<(), SolrError> {
// Search and retrieve the document
let docs = client
.select(
&SelectQueryBuilder::new().fq(&["id:example_document"]),
&SelectQuery::new().fq(["id:example_document"]),
"example_collection",
)
.await?
.get_response()
.get_docs_response()
.ok_or("No response provided")?
.get_docs::<TestData>()?;

// Delete the document
client
.delete(
&DeleteQueryBuilder::new().ids(&["example_document"]),
&DeleteQuery::new().ids(["example_document"]),
"example_collection",
)
.await?;
Expand All @@ -91,7 +93,7 @@ import asyncio
from solrstice.clients import AsyncSolrCloudClient
from solrstice.hosts import SolrSingleServerHost, SolrServerContext
from solrstice.auth import SolrBasicAuth
from solrstice.queries import UpdateQueryBuilder, SelectQueryBuilder, DeleteQueryBuilder
from solrstice.queries import UpdateQuery, SelectQuery, DeleteQuery

# A SolrServerContext specifies how the library should interact with Solr
context = SolrServerContext(SolrSingleServerHost('localhost:8983'), SolrBasicAuth('solr', 'SolrRocks'))
Expand All @@ -103,14 +105,14 @@ async def main():
await client.create_collection('example_collection', 'example_config', shards=1, replication_factor=1)

# Index a document
await client.index(UpdateQueryBuilder(), 'example_collection', [{'id': 'example_document', 'title': 'Example document'}])
await client.index(UpdateQuery(), 'example_collection', [{'id': 'example_document', 'title': 'Example document'}])

# Search for the document
response = await client.select(SelectQueryBuilder(fq=['title:Example document']), 'example_collection')
docs = response.get_response().docs
response = await client.select(SelectQuery(fq=['title:Example document']), 'example_collection')
docs = response.get_docs_response().get_docs()

# Delete the document
await client.delete(DeleteQueryBuilder(ids=['example_document']), 'example_collection')
await client.delete(DeleteQuery(ids=['example_document']), 'example_collection')


asyncio.run(main())
Expand Down
7 changes: 4 additions & 3 deletions framework/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "solrstice"
description = "A Solr 8+ client"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
license = "MIT OR Apache-2.0"
keywords = ["solr", "search"]
Expand All @@ -24,10 +24,11 @@ zip = { version = "0.6", default-features = false }
tempfile = "3.3"
walkdir = "2.3"
tokio = { version = "1.25", optional = true }
lazy_static = {version = "1.4", optional = true}
lazy_static = {version = "1.4"}
dyn-clone = "1.0"
regex = "1"
[features]
blocking = ["tokio", "lazy_static"]
blocking = ["tokio"]

[dev-dependencies]
tokio = { features = ["macros", "rt", "rt-multi-thread"], version = "1.25.0"}
Expand Down
14 changes: 8 additions & 6 deletions framework/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ It also provides a wrapper to python.
* Select Documents
* Grouping Component Query
* DefTypes (lucene, dismax, edismax)
* Facet Counts (Query, Field, Pivot)
* Json Facet (Query, Stat, Terms, Nested)
* Indexing Documents
* Deleting Documents
## Examples
Expand All @@ -22,8 +24,8 @@ use solrstice::hosts::solr_server_host::SolrSingleServerHost;
use solrstice::models::auth::SolrBasicAuth;
use solrstice::models::context::SolrServerContextBuilder;
use solrstice::models::error::SolrError;
use solrstice::queries::index::{DeleteQueryBuilder, UpdateQueryBuilder};
use solrstice::queries::select::SelectQueryBuilder;
use solrstice::queries::index::{DeleteQuery, UpdateQuery};
use solrstice::queries::select::SelectQuery;
use std::path::Path;

#[derive(Serialize, Deserialize, Debug)]
Expand Down Expand Up @@ -55,7 +57,7 @@ pub async fn example() -> Result<(), SolrError> {
}];
client
.index(
&UpdateQueryBuilder::new(),
&UpdateQuery::new(),
"example_collection",
docs.as_slice(),
)
Expand All @@ -64,18 +66,18 @@ pub async fn example() -> Result<(), SolrError> {
// Search and retrieve the document
let docs = client
.select(
&SelectQueryBuilder::new().fq(&["id:example_document"]),
&SelectQuery::new().fq(["id:example_document"]),
"example_collection",
)
.await?
.get_response()
.get_docs_response()
.ok_or("No response provided")?
.get_docs::<TestData>()?;

// Delete the document
client
.delete(
&DeleteQueryBuilder::new().ids(&["example_document"]),
&DeleteQuery::new().ids(["example_document"]),
"example_collection",
)
.await?;
Expand Down
8 changes: 4 additions & 4 deletions framework/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@ let docs = vec![TestData {
id: "example_document".to_string(),
}];
client
.index( &UpdateQueryBuilder::new(), "example_collection", docs.as_slice())
.index( &UpdateQuery::new(), "example_collection", docs.as_slice())
.await?;
```
### Selecting data
```rust
let docs = client
.select(
&SelectQueryBuilder::new().fq(&["id:example_document"]),
&SelectQuery::new().fq(["id:example_document"]),
"example_collection",
)
.await?
.get_response()
.get_docs_response()
.ok_or("No response provided")?
.get_docs::<TestData>()?;
```
### Deleting data
```rust
client
.delete(
&DeleteQueryBuilder::new().ids(&["example_document"]),
&DeleteQuery::new().ids(["example_document"]),
"example_collection",
)
.await?;
Expand Down
Loading

0 comments on commit 47e73a3

Please sign in to comment.