Credo che si sta utilizzando standard
analizzatore, che si divide in due http://example.dom
gettoni - http
e example.com
. Puoi dare un'occhiata http://localhost:9200/_analyze?text=http://example.com&analyzer=standard
.
Se si desidera dividere url
, è necessario utilizzare diverso analyzer o specificare il proprio custom analyzer.
Puoi dare un'occhiata come sarebbe url
indicizzato con simple analyzer - http://localhost:9200/_analyze?text=http://example.com&analyzer=simple
. Come puoi vedere, ora è url
indicizzato come tre token ['http', 'example', 'com']
. Se non si desidera indicizzare i token come ['http', 'www']
ecc., È possibile specificare l'analizzatore con lowercase tokenizer (questo è quello utilizzato nell'analizzatore semplice) e stop filter. Per esempio qualcosa di simile:
# Delete index
#
curl -s -XDELETE 'http://localhost:9200/url-test/' ; echo
# Create index with mapping and custom index
#
curl -s -XPUT 'http://localhost:9200/url-test/' -d '{
"mappings": {
"document": {
"properties": {
"content": {
"type": "string",
"analyzer" : "lowercase_with_stopwords"
}
}
}
},
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
},
"analysis": {
"filter" : {
"stopwords_filter" : {
"type" : "stop",
"stopwords" : ["http", "https", "ftp", "www"]
}
},
"analyzer": {
"lowercase_with_stopwords": {
"type": "custom",
"tokenizer": "lowercase",
"filter": [ "stopwords_filter" ]
}
}
}
}
}' ; echo
curl -s -XGET 'http://localhost:9200/url-test/_analyze?text=http://example.com&analyzer=lowercase_with_stopwords&pretty'
# Index document
#
curl -s -XPUT 'http://localhost:9200/url-test/document/1?pretty=true' -d '{
"content" : "Small content with URL http://example.com."
}'
# Refresh index
#
curl -s -XPOST 'http://localhost:9200/url-test/_refresh'
# Try to search document
#
curl -s -XGET 'http://localhost:9200/url-test/_search?pretty' -d '{
"query" : {
"query_string" : {
"query" : "content:example"
}
}
}'
NOTA: Se non si desidera utilizzare stopwords qui è interessante articolo stop stopping stop words: a look at common terms query
grazie @vhyza. Ho aggiornato la domanda con come ho creato l'indice. Ho una proprietà nidificata e voglio rimuovere il codice html. –
Prego. Le proprietà annidate dovrebbero andare bene. Puoi aggiungere 'char_filter' in' lowercase_with_stopwords' per rimuovere html se vuoi. – vhyza