55.TF/IDF algorithm

Source: Internet
Author: User
Tags idf

Key points of knowledge:

    • TF/IDF Algorithm Introduction
    • View es Calculation _source the process and the score of each entry
    • View a Document how it was matched to the

First, the algorithm introduction

Relevance Score The algorithm, in a nutshell, is to calculate the degree to which the text in an index matches the search text, and the correlation between them. Elasticsearch uses the term frequency/inverse document frequency algorithm, referred to as tf/ IDF Algorithm

1.Term Frequency

each entry in the search text is Field How many occurrences of the text, the more occurrences , the more relevant

Example

Search Request: Hello World

Doc1 : Hello, and world is very good

doc2 : Hello, how is it

Doc1 more relevant than DOC2

2.Inverse Document Frequency

The more occurrences of each entry in the search text in all documents throughout the index, the more irrelevant it is.

Search Request: Hello World

Doc1 : Hello, today is very good

doc2 : Hi World.

For example, inIndexin a1million BarDocument,HelloThis word is in all theDocument, there was a total of +times; WorldThis word is in all theDocument, there was a total of -times, thendoc2thanDoc1more relevant

3,field-length norm

The longer the field, the weaker the correlation

Search Request: Hello World

Doc1 : {"title": "Hello article", "Content": "Babaaba 1 words "}

doc2 : {"title": "My article", "Content": "Blablabala 1 words,hi World"}

Hello World in the entire Index is the same number of occurrences, but Word is only present in 10,000 words, so Doc1 more relevant, Title Field even shorter

Second, see How the _score is calculated

Get/test_index/test_type/_search?explain

{

"Query": {

"Match": {

"Test_field": "Test Hello"

}

}

}

third, see how a document is matched to

Get/test_index/test_type/6/_explain

{

"Query": {

"Match": {

"Test_field": "Test Hello"

}

}

}

Iv. Extension of Reading

Baidu Encyclopedia

 

55.TF/IDF algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.