#423: fulltext search by default

This commit is contained in:
bgamard 2020-08-28 17:33:27 +02:00
parent e474e7cd75
commit 42e61d6e1f
5 changed files with 25 additions and 16 deletions

View File

@ -39,7 +39,9 @@ public class SearchQueryBuilder {
*/ */
public SearchQueryBuilder simpleSearch(String simpleSearch) { public SearchQueryBuilder simpleSearch(String simpleSearch) {
if (isValid(simpleSearch)) { if (isValid(simpleSearch)) {
query.append(SEARCH_SEPARATOR).append(simpleSearch); query.append(SEARCH_SEPARATOR)
.append("simple:")
.append(simpleSearch);
} }
return this; return this;
} }

View File

@ -36,7 +36,7 @@
"argparse": { "argparse": {
"version": "1.0.10", "version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"requires": { "requires": {
"sprintf-js": "~1.0.2" "sprintf-js": "~1.0.2"
} }
@ -90,7 +90,7 @@
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -441,7 +441,7 @@
"log-symbols": { "log-symbols": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz",
"integrity": "sha1-V0Dhxdbw39pK2TI7UzIQfva0xAo=", "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==",
"requires": { "requires": {
"chalk": "^2.0.1" "chalk": "^2.0.1"
} }
@ -462,12 +462,12 @@
"mimic-fn": { "mimic-fn": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",
"integrity": "sha1-ggyGo5M0ZA6ZUWkovQP8qIBX0CI=" "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ=="
}, },
"minimatch": { "minimatch": {
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@ -534,7 +534,7 @@
"preferences": { "preferences": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/preferences/-/preferences-1.0.2.tgz", "resolved": "https://registry.npmjs.org/preferences/-/preferences-1.0.2.tgz",
"integrity": "sha1-UDaZN8ZpBIoEPKF+REaEQ278WUU=", "integrity": "sha512-cRjA8Galk1HDDBOKjx6DhTwfy5+FVZtH7ogg6rgTLX8Ak4wi55RaS4uRztJuVPd+md1jZo99bH/h1Q9bQQK8bg==",
"requires": { "requires": {
"graceful-fs": "^4.1.2", "graceful-fs": "^4.1.2",
"js-yaml": "^3.10.0", "js-yaml": "^3.10.0",
@ -556,7 +556,7 @@
"recursive-readdir": { "recursive-readdir": {
"version": "2.2.2", "version": "2.2.2",
"resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz", "resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz",
"integrity": "sha1-mUb7MnThYo3m42svZxSVO0hFCU8=", "integrity": "sha512-nRCcW9Sj7NuZwa2XvH9co8NPeXUBhZP7CRKJtU+cS6PW9FpCIFoI5ib0NT1ZrbNuPoRy0ylyCaUL8Gih4LSyFg==",
"requires": { "requires": {
"minimatch": "3.0.4" "minimatch": "3.0.4"
} }
@ -674,7 +674,7 @@
"string-width": { "string-width": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
"integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
"requires": { "requires": {
"is-fullwidth-code-point": "^2.0.0", "is-fullwidth-code-point": "^2.0.0",
"strip-ansi": "^4.0.0" "strip-ansi": "^4.0.0"
@ -714,7 +714,7 @@
"tmp": { "tmp": {
"version": "0.0.33", "version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
"integrity": "sha1-bTQzWIl2jSGyvNoKonfO07G/rfk=", "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==",
"requires": { "requires": {
"os-tmpdir": "~1.0.2" "os-tmpdir": "~1.0.2"
} }

View File

@ -455,8 +455,8 @@ public class DocumentResource extends BaseResource {
for (String criteria : criteriaList) { for (String criteria : criteriaList) {
String[] params = criteria.split(":"); String[] params = criteria.split(":");
if (params.length != 2 || Strings.isNullOrEmpty(params[0]) || Strings.isNullOrEmpty(params[1])) { if (params.length != 2 || Strings.isNullOrEmpty(params[0]) || Strings.isNullOrEmpty(params[1])) {
// This is not a special criteria // This is not a special criteria, do a fulltext search on it
query.add(criteria); fullQuery.add(criteria);
continue; continue;
} }
@ -588,12 +588,16 @@ public class DocumentResource extends BaseResource {
// New shared state criteria // New shared state criteria
documentCriteria.setActiveRoute(params[1].equals("me")); documentCriteria.setActiveRoute(params[1].equals("me"));
break; break;
case "simple":
// New simple search criteria
query.add(params[1]);
break;
case "full": case "full":
// New full content search criteria // New fulltext search criteria
fullQuery.add(params[1]); fullQuery.add(params[1]);
break; break;
default: default:
query.add(criteria); fullQuery.add(criteria);
break; break;
} }
} }

View File

@ -173,7 +173,10 @@ angular.module('docs').controller('Document', function ($scope, $rootScope, $tim
$scope.startSearch = function () { $scope.startSearch = function () {
var search = ''; var search = '';
if (!_.isEmpty($scope.advsearch.search_simple)) { if (!_.isEmpty($scope.advsearch.search_simple)) {
search += $scope.advsearch.search_simple + ' '; var simplesearch = _.map($scope.advsearch.search_simple.split(/\s+/), function (simple) {
return 'simple:' + simple
});
search += simplesearch.join(' ') + ' ';
} }
if (!_.isEmpty($scope.advsearch.search_fulltext)) { if (!_.isEmpty($scope.advsearch.search_fulltext)) {
var fulltext = _.map($scope.advsearch.search_fulltext.split(/\s+/), function (full) { var fulltext = _.map($scope.advsearch.search_fulltext.split(/\s+/), function (full) {

View File

@ -216,7 +216,7 @@ public class TestDocumentResource extends BaseJerseyTest {
Assert.assertEquals(2, searchDocuments("lang:eng", document1Token)); Assert.assertEquals(2, searchDocuments("lang:eng", document1Token));
Assert.assertEquals(1, searchDocuments("mime:image/png", document1Token)); Assert.assertEquals(1, searchDocuments("mime:image/png", document1Token));
Assert.assertEquals(0, searchDocuments("mime:empty/void", document1Token)); Assert.assertEquals(0, searchDocuments("mime:empty/void", document1Token));
Assert.assertEquals(1, searchDocuments("after:2010 before:2040-08 tag:super shared:yes lang:eng title description full:uranium", document1Token)); Assert.assertEquals(1, searchDocuments("after:2010 before:2040-08 tag:super shared:yes lang:eng simple:title simple:description full:uranium", document1Token));
// Search documents (nothing) // Search documents (nothing)
Assert.assertEquals(0, searchDocuments("random", document1Token)); Assert.assertEquals(0, searchDocuments("random", document1Token));