Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8461099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:47:09+00:00 2026-06-10T13:47:09+00:00

If I write and algorithm that performs a search using Lucene how can I

  • 0

If I write and algorithm that performs a search using Lucene how can I state the computational complexity of it? I know that Lucene uses tf*idf scoring but I don’t know how it is implemented. I’ve found that tf*idf has the following complexity:

O(|D|+|T|) 

where D is the set of documents and T the set of all terms.

However, I need someone who could check if this is correct and explain me why.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:47:11+00:00Added an answer on June 10, 2026 at 1:47 pm

    Lucene basically uses a Vector Space Model (VSM) with a tf-idf scheme. So, in the standard setting we have:

    • A collection of documents each represented as a vector
    • A text query also represented as a vector

    We determine the K documents of the collection with the highest vector space scores on the query q. Typically, we seek these K top documents ordered by score in decreasing order; for instance many search engines use K = 10 to retrieve and rank-order the first page of the ten best results.

    The basic algorithm for computing vector space scores is:

    float Scores[N] = 0
    Initialize Length[N]
    for each query term t
    do calculate w(t,q) and fetch postings list for t (stored in the index)
        for each pair d,tf(t,d) in postings list
        do Scores[d] += wf(t,d) X w(t,q)  (dot product)
    Read the array Length[d]
    for each d
    do Scored[d] = Scores[d] / Length[d]
    return Top K components of Scores[]
    

    Where

    • The array Length holds the lengths (normalization factors) for each of the N
      documents, whereas the array Scores holds the scores for each of the documents.
    • tf is the term frequency of a term in a document.
    • w(t,q) is the weight of the submitted query for a given term. Note that query is treated as a bag of words and the vector of weights can be considered (as if it was another document).
    • wf(d,q) is the logarithmic term weighting for query and document

    As described here: Complexity of vector dot-product, vector dot-product is O(n). Here the dimension is the number of terms in our vocabulary: |T|, where T is the set of terms.

    So, the time complexity of this algorithm is:

    O(|Q|· |D| · |T|) = O(|D| · |T|) 
    

    we consider |Q| fixed, where Q is the set of words in the query (which average size is low, in average a query has between 2 and 3 terms) and D is the set of all documents.

    However, for a search, these sets are bounded and indexes don’t tend to grow very often. So, as a result, searches using VSM are really fast (when T and D are large the search is really slow and one has to find an alternative approach).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write and algorithm that can detect which state an application (used
I have an assignment that wants me to write an ternary search algorithm and
How can I write an algorithm that given a floating point number, and attempts
I want to write an algorithm that can take parts of a picture and
I need to write an algorithm that reads keyboard stream until it gets a
I have to write an algorithm that find the path in DAG with single
I'm trying to write an algorithm that will let me iterate over all desired
I am trying to write an efficient algorithm that will effectively let me merge
I use a generic algorithm to write CSV files that in theory works for
So I know of a few people that actually write their algorithms out in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.