elasticsearch-minhash icon indicating copy to clipboard operation
elasticsearch-minhash copied to clipboard

Doing fuzzy search or more_like_this query on minhash type?

Open Fred12 opened this issue 5 years ago • 2 comments

Hello, I tried to perform a search query on the stored minhash_field... e.g with the fuzzy search or with the more_like_this query .... but I get an error it cannot use the query on type minhash:

GET /test_minhash/_doc/_search/ { "query": { "fuzzy" : { "minhash_value" : { "value": "reKED0r9qtIDAC8JIpx8Dw==", "boost": 1.0, "fuzziness": 5, "prefix_length": 0, "max_expansions": 100 } } }, "stored_fields": ["minhash_value"] }

============================================================ { "error": { "root_cause": [ { "type": "query_shard_exception", "reason": "failed to create query: {\n "fuzzy" : {\n "minhash_value" : {\n "value" : "reKED0r9qtIDAC8JIpx8Dw==",\n "fuzziness" : "5",\n "prefix_length" : 0,\n "max_expansions" : 100,\n "transpositions" : false,\n "boost" : 1.0\n }\n }\n}", "index_uuid": "FjpcyDT3RIK__bSA5JG1yg", "index": "test_minhash" } ], "type": "search_phase_execution_exception", "reason": "all shards failed", "phase": "query", "grouped": true, "failed_shards": [ { "shard": 0, "index": "test_minhash", "node": "A_Rbp6ykRxOP6R-KYRZTeA", "reason": { "type": "query_shard_exception", "reason": "failed to create query: {\n "fuzzy" : {\n "minhash_value" : {\n "value" : "reKED0r9qtIDAC8JIpx8Dw==",\n "fuzziness" : "5",\n "prefix_length" : 0,\n "max_expansions" : 100,\n "transpositions" : false,\n "boost" : 1.0\n }\n }\n}", "index_uuid": "FjpcyDT3RIK__bSA5JG1yg", "index": "test_minhash", "caused_by": { "type": "illegal_argument_exception", "reason": "Can only use fuzzy queries on keyword and text fields - not on [minhash_value] which is of type [minhash]" } } } ] }, "status": 400 }

what is the best approach how to do this?

Fred12 avatar Mar 15 '19 10:03 Fred12

See a source code of Fess. Fess uses copy_bits_to.

marevol avatar Mar 15 '19 14:03 marevol

Thanks for the info, however, I was using it in kibana, but I couldnt retieve the bits keyword field in GET...

PUT /test_minhash_test { "index":{ "analysis":{ "analyzer":{ "minhash_analyzer":{ "type":"custom", "tokenizer":"standard", "filter":["minhash"] } } } } }

PUT /test_minhash_test/_doc/_mapping { "_doc":{ "properties":{ "message": { "type":"text", "copy_to":"minhash_value" }, "minhash_value":{ "type":"minhash", "minhash_analyzer":"minhash_analyzer", "store":true, "copy_bits_to": "content_minhash_bits" }, "content_minhash_bits": { "type": "keyword", "store":true } } } }

GET /test_minhash_test/_doc/_search/?pretty&stored_fields=*

Fred12 avatar Mar 18 '19 08:03 Fred12