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 6617135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:40:05+00:00 2026-05-25T20:40:05+00:00

There’s a large set of entities of different kinds: interface Entity { } interface

  • 0

There’s a large set of entities of different kinds:

interface Entity {
}

interface Entity1 extends Entity {
  String field1();
  String field2();
}

interface Entity2 extends Entity {
  String field1();
  String field2();
  String field3();
}

interface Entity3 extends Entity {
  String field12();
  String field23();
  String field34();
}

Set<Entity> entities = ...

The task is to implement full text search for this set. By full text search I mean I just need to get entities that contain a substring I’m looking for (I don’t need to know exact property, exact offset of where this substrig is, etc). In current implementation the Entity interface has a method matches(String):

interface Entity {
  boolean matches(String text);
}

Each entity class implements it depending on its internals:

class Entity1Impl implements Entity1 {
  public String field1() {...}
  public String field2() {...}

  public boolean matches(String text) {
    return field1().toLowerCase().contains(text.toLowerCase()) ||
           field2().toLowerCase().contains(text.toLowerCase());
  }
}

I believe this approach is really awful (though, it works). I’m considering using Lucene to build indexes every time I have a new set. By index I mean content -> id mappings. The content is just a trivial “sum” of all the fields I’m considering. So, for Entity1 the content would be concatenation of field1() and field2(). I have some doubts about the performance: building the index is often quite an expensive operation, so I’m not really sure if it helps.

Do you have any other suggestions?

To clarify the details:

  1. Set<Entity> entities = ... is of ~10000 items.
  2. Set<Entity> entities = ... is not read from DB, so I can’t just add where ... condition. The data source is quite non-trivial, so I can’t solve the problem on its side.
  3. Entities should be thought of as of short articles, so some fields may be up to 10KB, while others may be ~10 bytes.
  4. I need to perform this search quite often, but both the query string and original set are different every time, so it looks like I can’t just build index once (because the set of entities is different every time).
  • 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-05-25T20:40:05+00:00Added an answer on May 25, 2026 at 8:40 pm

    For such a complex Object domain, you can use lucene wrapper tool like Compass which allow quickly map you object graph to lucene index using the same approach as ORM(like hibernate)

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

Sidebar

Related Questions

There are many string matching algorithms can be used to find a pattern (string)
There is a website called Gild.com that has different coding puzzles/challenges for users to
There doesn't seem to be any tried and true set of best practices to
There are many free online services which provides you with large spaces to store
there is an array in c# string[] arr = new string[] {1,A,D,3,5,AF,34,TU,E,OP,4}; so how
There are many algorithms for finding optimal binary search trees given a set of
There is a conversion process that is needed when migrating Visual Studio 2005 web
There are two weird operators in C#: the true operator the false operator If
There are two popular closure styles in javascript. The first I call anonymous constructor
There is previous little on the google on this subject other than people asking

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.