2017-05-02 2 views
1

Änderung der Ähnlichkeit Algorithmus meines Index funktioniert nicht. Ich möchte BM25 vs. TF-IDF vergleichen, aber ich bekomme immer die gleichen Ergebnisse. Ich verwende Elasticsearch 5.x.Elasticsearch Änderung der Ähnlichkeit funktioniert nicht

Ich habe buchstäblich alles versucht. Einstellen der Ähnlichkeit einer Eigenschaft classic oder BM25 oder stellen Sie nichts

"properties": { 
      "content": { 
       "type": "text", 
       "similarity": "classic" 
      }, 

Ich versuchte auch in der settings den Standard similarty meiner Index setzen und es in der properties

"settings": { 
    "index": { 
     "number_of_shards": "5", 
     "provided_name": "test", 
     "similarity": { 
      "default": { 
       "type": "classic" 
      } 
     }, 
     "creation_date": "1493748517301", 
     "number_of_replicas": "1", 
     "uuid": "sNuWcT4AT82MKsfAB9JcXQ", 
     "version": { 
      "created": "5020299" 
     } 
    } 

Die Verwendung Abfrage im Test sieht ungefähr so ​​aus:

{ 
    "query": { 
    "match": { 
     "content": "some search query" 
    } 
    } 
} 

Antwort

1

ich eine Probe unter erstellt haben:

DELETE test 
PUT test 
{ 
    "mappings": { 
    "book": { 
     "properties": { 
     "content": { 
      "type": "text", 
      "similarity": "BM25" 
     }, 
     "subject": { 
      "type": "text", 
      "similarity": "classic" 
     } 
     } 
    } 
    } 
} 

POST test/book/1 
{ 
    "subject": "A neutron star is the collapsed core of a large (10–29 solar masses) star. Neutron stars are the smallest and densest stars known to exist.[1] Though neutron stars typically have a radius on the order of 10 km, they can have masses of about twice that of the Sun.", 
    "content": "A neutron star is the collapsed core of a large (10–29 solar masses) star. Neutron stars are the smallest and densest stars known to exist.[1] Though neutron stars typically have a radius on the order of 10 km, they can have masses of about twice that of the Sun." 
} 
POST test/book/2 
{ 
    "subject": "A quark star is a hypothetical type of compact exotic star composed of quark matter, where extremely high temperature and pressure forces nuclear particles to dissolve into a continuous phase consisting of free quarks. These are ultra-dense phases of degenerate matter theorized to form inside neutron stars exceeding a predicted internal pressure needed for quark degeneracy.", 
    "content": "A quark star is a hypothetical type of compact exotic star composed of quark matter, where extremely high temperature and pressure forces nuclear particles to dissolve into a continuous phase consisting of free quarks. These are ultra-dense phases of degenerate matter theorized to form inside neutron stars exceeding a predicted internal pressure needed for quark degeneracy." 
} 

GET test/_search?explain 
{ 
    "query": { 
    "match": { 
     "subject": "neutron" 
    } 
    } 
} 
GET test/_search?explain 
{ 
    "query": { 
    "match": { 
     "content": "neutron" 
    } 
    } 
} 

subject und content Felder haben unterschiedliche Definitionen Ähnlichkeiten, aber in den beiden Dokumenten I (aus Wikipedia) sie den gleichen Text in ihnen haben. Laufen die beiden Fragen, die Sie in den Erklärungen so etwas wie dies sehen und auch verschiedene Noten in Ergebnisse erhalten:

  • von der ersten Abfrage: "description": "idf, computed as log((docCount+1)/(docFreq+1)) + 1 from:"
  • von der zweiten: "description": "idf, computed as log(1 + (docCount - docFreq + 0.5)/(docFreq + 0.5)) from:",
+0

Perfekt danke, Ich weiß jetzt, was ich falsch gemacht habe. Das erklärte es. Ich habe die Messungen falsch berechnet. Und ich habe herausgefunden, dass BM25 die Standardeinstellung ist! –

+0

Kühl. Danke für das Follow-up. –

Verwandte Themen