Skip to content

Commit

Permalink
migrated nbHits to estimatedTotalHits
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Jul 17, 2022
1 parent bdb1cbe commit 9564038
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 26 deletions.
20 changes: 10 additions & 10 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ paths:
name: 'Gebäudeteil 3, Institut für Produktionstechnik'
subtext: Gebäudeteil
n_visible: 5
nb_hits: 20
estimatedTotalHits: 20
- facet: rooms
entries:
- id: 5510.03.002
Expand Down Expand Up @@ -161,17 +161,17 @@ paths:
name: 5503.EG.350 (Egbert-von-Hoyer-Hörsaal)
subtext: Maschinenwesen (MW)
subtext_bold: 0350@5503
nb_hits: 3655
estimatedTotalHits: 3655
time_ms: 16
nothing:
value:
sections:
- facet: sites_buildings
entries: []
nb_hits: 0
estimatedTotalHits: 0
- facet: rooms
entries: []
nb_hits: 0
estimatedTotalHits: 0
time_ms: 6
interims-2:
value:
Expand All @@ -183,7 +183,7 @@ paths:
name: "\x19Interims\x17hörsäle II, Jürgen Manchot-Hörsaalgebäude"
subtext: Gebäude
n_visible: 1
nb_hits: 1
estimatedTotalHits: 1
- facet: rooms
entries:
- id: 5416.01.004
Expand Down Expand Up @@ -211,7 +211,7 @@ paths:
name: 5416.EG.010 (IT/Audio)
subtext: 'Interimshörsäle II, Jürgen Manchot-Hörsaalgebäude'
subtext_bold: 010@5416
nb_hits: 23
estimatedTotalHits: 23
time_ms: 23
'400':
description: Invalid Request
Expand Down Expand Up @@ -1150,7 +1150,7 @@ components:
example: rooms
enum:
- rooms
nb_hits:
estimatedTotalHits:
description: The estimated (not exact) number of hits for that query
type: integer
format: int64
Expand All @@ -1160,7 +1160,7 @@ components:
items:
$ref: '#/components/schemas/RoomEntry'
required:
- nb_hits
- estimatedTotalHits
- facet
- entries
SitesBuildings:
Expand All @@ -1172,7 +1172,7 @@ components:
example: sites_buildings
enum:
- sites_buildings
nb_hits:
estimatedTotalHits:
description: The estimated (not exact) number of hits for that query
type: integer
format: int64
Expand All @@ -1191,7 +1191,7 @@ components:
format: int64
minimum: 0
required:
- nb_hits
- estimatedTotalHits
- facet
- entries
RoomEntry:
Expand Down
4 changes: 2 additions & 2 deletions server/src/core/search/search_executor/meilisearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ struct MSQuery<'a> {
#[allow(dead_code)]
pub(super) struct MSResults {
pub(super) hits: Vec<MSHit>,
#[serde(rename = "nbHits")]
pub(super) nb_hits: i32,
#[serde(rename = "estimatedTotalHits")]
pub(super) estimated_total_hits: i32,
#[serde(rename = "facetsDistribution")]
pub(super) facets_distribution: MSFacetDistribution,
}
Expand Down
3 changes: 2 additions & 1 deletion server/src/core/search/search_executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ pub struct SearchResultsSection {
entries: Vec<ResultEntry>,
#[serde(skip_serializing_if = "Option::is_none")]
n_visible: Option<usize>,
nb_hits: i32,
#[serde(rename = "estimatedTotalHits")]
estimated_total_hits: i32,
}

#[derive(Serialize, Debug, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions server/src/core/search/search_executor/postprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ pub(super) fn merge_search_results(
facet: "sites_buildings".to_string(),
entries: Vec::<super::ResultEntry>::new(),
n_visible: None,
nb_hits: facet.get("site").unwrap_or(&0) + facet.get("building").unwrap_or(&0),
estimated_total_hits: facet.get("site").unwrap_or(&0) + facet.get("building").unwrap_or(&0),
};
let mut section_rooms = super::SearchResultsSection {
facet: "rooms".to_string(),
entries: Vec::<super::ResultEntry>::new(),
n_visible: None,
nb_hits: res_rooms.nb_hits,
estimated_total_hits: res_rooms.estimated_total_hits,
};

// TODO: Collapse joined buildings
Expand Down
2 changes: 1 addition & 1 deletion server/test/search_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def do_search(q_str):
"query": q["query"],
"target": q["target"],
"hits": list(itertools.chain(*[s["entries"] for s in r["sections"]])),
"num_results": sum([s["nb_hits"] for s in r["sections"]]),
"num_results": sum([s["estimatedTotalHits"] for s in r["sections"]]),
"time_ms": r["time_ms"],
}

Expand Down
4 changes: 2 additions & 2 deletions webclient/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@
+{{ s.entries.length - s.n_visible }} ${{_.search.hidden}}$,
</a>
<template>
{{ s.nb_hits > 20 ? "${{_.search.approx}}$ " : "" }}{{ s.nb_hits }}
{{ s.nb_hits === 1 ? "${{_.search.result}}$" : "${{_.search.results}}$" }}
{{ s.estimatedTotalHits > 20 ? "${{_.search.approx}}$ " : "" }}{{ s.estimatedTotalHits }}
{{ s.estimatedTotalHits === 1 ? "${{_.search.result}}$" : "${{_.search.results}}$" }}
</template>
</li>
</template>
Expand Down
4 changes: 2 additions & 2 deletions webclient/src/modules/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ navigatum.registerModule("autocomplete", (function() {
name: "${{ _.search.sections.buildings }}$",
expanded: false,
entries: entries,
nb_hits: data.sections[i].nb_hits,
estimatedTotalHits: data.sections[i].estimatedTotalHits,
n_visible: data.sections[i].n_visible,
});
} else if (data.sections[i].facet == "rooms") {
sections.push({
name: "${{ _.search.sections.rooms }}$",
entries: entries,
nb_hits: data.sections[i].nb_hits,
estimatedTotalHits: data.sections[i].estimatedTotalHits,
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions webclient/src/views/search/view-search.inc
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
</li>
</ul>
<div class="search-comment nb_results">
{{ s.nb_hits > 20 ? "${{_.search.approx}}$ " : "" }}{{ s.nb_hits }}
{{ s.nb_hits === 1 ? "${{_.search.result}}$" : "${{_.search.results}}$" }}{{ s.nb_hits > 10 ? ", ${{_.view_search.max_results }}$" : ""}}
{{ s.estimatedTotalHits > 20 ? "${{_.search.approx}}$ " : "" }}{{ s.estimatedTotalHits }}
{{ s.estimatedTotalHits === 1 ? "${{_.search.result}}$" : "${{_.search.results}}$" }}{{ s.estimatedTotalHits > 10 ? ", ${{_.view_search.max_results }}$" : ""}}
</div>
</section>
</template>
Expand Down
8 changes: 4 additions & 4 deletions webclient/src/views/search/view-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ navigatum.registerView('search', {
let sections_descr=""
let found_total=0
for (const section of data.sections){
if (section.nb_hits) {
if (section.estimatedTotalHits) {
let facet_str
if (section.facet === "sites_buildings") {
facet_str="${{ _.search.sections.buildings }}$"
if (section.nb_hits!==section.n_visible) {
if (section.estimatedTotalHits!==section.n_visible) {
const visible_str = "${{ _.search.sections.of_which_visible }}$"
facet_str = `(${section.n_visible} ${visible_str}) ${facet_str}`
}
Expand All @@ -57,9 +57,9 @@ navigatum.registerView('search', {
facet_str="${{ _.search.sections.rooms }}$"
if (found_total>0)
sections_descr+=" ${{ _.search.sections.and }}$ "
sections_descr+= `${section.nb_hits} ${facet_str}`
sections_descr+= `${section.estimatedTotalHits} ${facet_str}`
}
found_total+=section.nb_hits
found_total+=section.estimatedTotalHits
}
if (found_total===0)
sections_descr = "${{ _.search.sections.no_buildings_rooms_found }}$"
Expand Down

0 comments on commit 9564038

Please sign in to comment.