Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve search indexing #595

Merged
merged 7 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
trace-*.json
**/.temp
.DS_Store
.cargo
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ See [STATUS.md](server/STATUS.md) to learn more about which features will remain

## UNRELEASED

- **Requires `--rebuild-index`**
- Improve full-text search, use JSON fields #335
- Update tantivy.
- Parse multiple auth cookies #525
- Fix `--script` flag

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ There are two ways you can use `tracing` to get insights into performance.
- Visit jaeger: `http://localhost:16686`

```sh
docker run -d --name jaeger \
docker run -d --platform linux/amd64 --name jaeger \
-e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
-p 5775:5775/udp \
-p 6831:6831/udp \
Expand Down
94 changes: 36 additions & 58 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions lib/src/db/query_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ pub fn query_indexed(store: &Db, q: &Query) -> AtomicResult<QueryResult> {
if in_selection {
let (k, _v) = kv.map_err(|_e| "Unable to parse query_cached")?;
let (_q_filter, _val, subject) = parse_collection_members_key(&k)?;

// If no external resources should be included, skip this one if it's an external resource
if !q.include_external && !subject.starts_with(&self_url) {
continue;
Expand All @@ -140,7 +139,7 @@ pub fn query_indexed(store: &Db, q: &Query) -> AtomicResult<QueryResult> {
"Error when getting resource in collection: {}",
&e
)
.into())
.into());
}
},
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/populate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn populate_base_models(store: &impl Storelike) -> AtomicResult<()> {
},
Property {
class_type: Some(urls::PROPERTY.into()),
data_type: DataType::AtomicUrl,
data_type: DataType::ResourceArray,
shortname: "allows-only".into(),
description: "Restricts this Property to only the values inside this one. This essentially turns the Property into an `enum`.".into(),
subject: urls::ALLOWS_ONLY.into(),
Expand Down
25 changes: 19 additions & 6 deletions lib/src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,25 @@ impl Resource {
) -> AtomicResult<()> {
let full_prop = store.get_property(&property)?;
if let Some(allowed) = full_prop.allows_only {
if !allowed.contains(&value.to_string()) {
return Err(format!(
"Property '{}' does not allow value '{}'. Allowed: {:?}",
property, value, allowed
)
.into());
let error = Err(format!(
"Property '{}' does not allow value '{}'. Allowed: {:?}",
property, value, allowed
)
.into());

match &value {
Value::ResourceArray(value_array) => {
for item in value_array {
if !allowed.contains(&item.to_string()) {
return error;
}
}
}
_ => {
if !allowed.contains(&value.to_string()) {
return error;
}
}
}
}
if full_prop.data_type == value.datatype() {
Expand Down
2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ rustls-pemfile = "1"
sanitize-filename = "0.4"
serde_json = "1"
static-files = "0.2"
tantivy = "0.18"
tantivy = "0.19"
tracing = "0.1"
tracing-actix-web = "0.6"
tracing-chrome = "0.6"
Expand Down
Loading