fulltextsearch icon indicating copy to clipboard operation
fulltextsearch copied to clipboard

fulltextsearch:search causes exception

Open sandetsky opened this issue 4 years ago • 6 comments

FulltextSearch doesn't search anything and causes an exception.

sudo -u apache php /var/www/html/nextcloud/occ fulltextsearch:search user test search

In Connection.php line 632:

{"error":{"root_cause":[{"type":"x_content_parse_exception","reason":"[1:63] [bool] failed to parse field [should]"}],"type":"x_content_parse_excep tion","reason":"[1:63] [bool] failed to parse field [must]","caused_by":{"type":"x_content_parse_exception","reason":"[1:63] [bool] failed to parse field [should]","caused_by":{"type":"x_content_parse_exception","reason":"[1:63] [bool] failed to parse field [should]","caused_by":{"type":"illeg al_state_exception","reason":"expected value but got [START_ARRAY]"}}}},"status":400}

Nextcloud 18.0.4

sandetsky avatar May 20 '20 08:05 sandetsky

The same exception while searching from the Web

sandetsky avatar May 20 '20 08:05 sandetsky

log entry in Nextcloud for me:

no app in context | 500 - {"request":{"providers":["files"],"author":"lars","search":"ratingen","page":1,"size":20,"parts":["comments","ocr"],"queries":[],"options":{"files_within_dir":"","files_local":"","files_external":"","files_extension":""},"metatags":[],"subtags":[],"tags":[]},"version":"1.4.1","status":-1,"exception":"Elasticsearch\\Common\\Exceptions\\BadRequest400Exception","message":"{\"error\":{\"root_cause\":[{\"type\":\"x_content_parse_exception\",\"reason\":\"[1:63] [bool] failed to parse field [should]\"}],\"type\":\"x_content_parse_exception\",\"reason\":\"[1:63] [bool] failed to parse field [must]\",\"caused_by\":{\"type\":\"x_content_parse_exception\",\"reason\":\"[1:63] [bool] failed to parse field [should]\",\"caused_by\":{\"type\":\"x_content_parse_exception\",\"reason\":\"[1:63] [bool] failed to parse field [should]\",\"caused_by\":{\"type\":\"illegal_state_exception\",\"reason\":\"expected value but got [START_ARRAY]\"}}}},\"status\":400}"} -- | --

i made an issue on elasticsearch https://github.com/elastic/elasticsearch/issues/57090

Happyfeet01 avatar May 24 '20 06:05 Happyfeet01

Ditto, the search is broken under 18.0.4.

Edit : with elasticsearch 7.7.0 ... thanks @Happyfeet01

prolibre avatar May 25 '20 14:05 prolibre

Depends on elasticsearch 7.7.0. With 7.6.2 it works

Happyfeet01 avatar May 25 '20 14:05 Happyfeet01

Elasticsearch 7.7.0 Nextcloud 18.0.4 Nextcloud App "fulltextsearch" 1.4.1 Nextcloud App "fulltextsearch - Elasticsearch Platform" 1.5.1 PHP 7.4

I have experienced the same. Behaviour can be observed when testing with ./occ fulltextsearch:test

user@host:/var/www/nextcloud/$ sudo --user www-data php ./occ fulltextsearch:test --platform_delay 30

.Testing your current setup:
Creating mocked content provider. ok
Testing mocked provider: get indexable documents. (2 items) ok
Loading search platform. (Elasticsearch) ok
Testing search platform. ok
Locking process ok
Removing test. ok
Pausing 30 seconds 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ok
Initializing index mapping. ok
Indexing generated documents. ok
Pausing 30 seconds 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ok
Retreiving content from a big index (license). (size: 32386) ok
Comparing document with source. ok
Searching basic keywords:
 - 'test' An unhandled exception has been thrown:
TypeError: Return value of OCA\FullTextSearch\Model\SearchRequest::getProviders() must be of the type array, null returned in /var/www/nextcloud/apps/fulltextsearch/lib/Model/SearchRequest.php:114
Stack trace:
#0 /var/www/nextcloud/apps/fulltextsearch/lib/Model/SearchRequest.php(700): OCA\FullTextSearch\Model\SearchRequest->getProviders()
#1 [internal function]: OCA\FullTextSearch\Model\SearchRequest->jsonSerialize()
#2 /var/www/nextcloud/apps/fulltextsearch_elasticsearch/lib/Service/SearchService.php(103): json_encode()
#3 /var/www/nextcloud/apps/fulltextsearch_elasticsearch/lib/Platform/ElasticSearchPlatform.php(336): OCA\FullTextSearch_ElasticSearch\Service\SearchService->searchRequest()
#4 /var/www/nextcloud/apps/fulltextsearch/lib/Command/Test.php(584): OCA\FullTextSearch_ElasticSearch\Platform\ElasticSearchPlatform->searchRequest()
#5 /var/www/nextcloud/apps/fulltextsearch/lib/Command/Test.php(436): OCA\FullTextSearch\Command\Test->search()
#6 /var/www/nextcloud/apps/fulltextsearch/lib/Command/Test.php(171): OCA\FullTextSearch\Command\Test->testSearchSimple()
#7 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(255): OCA\FullTextSearch\Command\Test->execute()
#8 /var/www/nextcloud/core/Command/Base.php(168): Symfony\Component\Console\Command\Command->run()
#9 /var/www/nextcloud/3rdparty/symfony/console/Application.php(915): OC\Core\Command\Base->run()
#10 /var/www/nextcloud/3rdparty/symfony/console/Application.php(272): Symfony\Component\Console\Application->doRunCommand()
#11 /var/www/nextcloud/3rdparty/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun()
#12 /var/www/nextcloud/lib/private/Console/Application.php(214): Symfony\Component\Console\Application->run()
#13 /var/www/nextcloud/console.php(99): OC\Console\Application->run()
#14 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')

Debug Log from Nextcloud:

[fulltextsearch_elasticsearch] 
Debug: 

Searching ES: 
{
	"index":"my_index",
	"type":"standard",
	"size":10,
	"from":0,
	"body":
	{"query":{"bool":{"must":{"bool":
		{
			"should":
			{
				"bool":
				{
					"should":
					[
						[
							{
								"bool":
								{
									"should":
									[
										{"match_phrase_prefix":{"content":"test"}},
										{"match_phrase_prefix":{"title":"test"}},
										{"match_phrase_prefix":{"share_names.user":"test"}},
										{"wildcard":{"title":"*test*"}},
										{"wildcard":{"share_names.user":"*test*"}},
										{"query_string":{"fields":["parts.comments"],"query":"test"}}
									]
								}
							}
						]
					]
				}
			}
		}
	},"filter":
	[
		{"bool":{"must":{"term":{"provider":"files"}}}},{"bool":{"should":[<<REDACTED>>]}},
		{"bool":{"should":[{"term":{"metatags":"files_local"}}]}},
		{"bool":{"must":[]}},{"bool":{"must":[]}}
	]}},"highlight":{"fields":{"content":{},"parts.comments":{}},"pre_tags":[""],"post_tags":[""]}
	}
}

https://discuss.elastic.co/t/must-not-boolean-query-in-7-7/233269/2 "We recently made a small change to the parsing logic for this particular query."

RoepLuke avatar May 28 '20 19:05 RoepLuke

The hotfix in the PR works. https://github.com/nextcloud/fulltextsearch_elasticsearch/pull/107

Happyfeet01 avatar May 28 '20 20:05 Happyfeet01