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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:38:24+00:00 2026-06-10T21:38:24+00:00

A few month ago I asked a similar question here . However I cannot

  • 0

A few month ago I asked a similar question here. However I cannot get it work properly:

I try to build a simple filename search. I want that the user can search
for any part of the filename.
Let’s say the following filenames are indexed:

[1] My_file_2012.01.12.txt
[2] My_file_2012.01.05.txt
[3] My_file_2012.05.01.txt
[4] My_file_2012.08.27.txt
[5] My_file_2012.12.12.txt
[6] My_file_2011.12.12.txt
[7] file_01_2012.09.09.txt

Then the user might search for:

"ile_20"                    (finds the first six documents)
"12.txt"                    (finds 1, 5, 6)
"12" followed by "01"       (finds 1, 2, 3 - NOT 7)
"2012" followed by "01"     (finds 1, 2, 3 - NOT 7)

(Note: Yes, the user might really search for strings like “ile_20” … e.g.
because of copy-and-paste mistakes)

Therefore I use a nGram-tokenizer to index each part of the filename. This
works fine so far.
To support the “followed by”-search mentioned above I need a query that
respects the order of the terms, no matter how many text is between these
two terms (okay let’s say max. 100 characters).

Since a “text_phrase”-query with a “slop” does not respect the ordering of
the terms correctly, I decided to use a “span_near” query. This works fine
in most cases.

See here my full example-index incl. error-description: click

As mentioned in the example above the query “‘2012′ followed by ’01′” does
not work since the nGram tokenizer generates a position-value for each
token, but these values are not very useful when used by the “span_near” query. While
indexing, the term “2012” is assigned to a position value (50) which is
bigger than the position value for the term “01” (e.g. 10). Since 50 and 10
are not in order the query will have no results. The in-order-thing works
only correct for terms which have the same length (e.g. “’12’ followed by
’01′”) or if the terms are ordered by length (e.g. “’20’ followed by
‘.12′”).

So how can I achieve the correct search-behaviour? I just want the ability
to search for any part(s) of the filename while respecting the order of the
terms.
Maybe there is a way to tell “span_near” to not use the position but
instead the “start_offset”?
Or is there another query I can use?

  • 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-10T21:38:26+00:00Added an answer on June 10, 2026 at 9:38 pm

    How about a wildcard search like this:

    “12” followed by “01” -> 12*01

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

Sidebar

Related Questions

A few months ago i asked the question below. My question. However, i have
I asked something similar a few days ago, here is my issue. My professor
Few times ago, I asked how to do to display data per month, I
I've asked here a ton of questions about WSAAsyncSelect and NET.Few months ago I
few month ago i write something to get the latitude or longitude from google
I asked a question a few months ago, to which Meteor seems to have
A few months ago I asked about UsernameToken and SSL in WCF 4 web
I went to the iPhone Developer Tech Talk a few months ago and asked
I started programming just few month ago so I am a pure beginner but
I had asked this question in a much more long-winded way a few days

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.