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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:40:17+00:00 2026-06-09T08:40:17+00:00

I am tyring to test Whoosh for text searching and right now a simple

  • 0

I am tyring to test Whoosh for text searching and right now a simple contrived example is not working for me. I assume I am missing something here. In the following code I would expect it give a single search result but I get 0 hits.

import sys
import os

from whoosh.fields import Schema, TEXT, STORED
from whoosh.index import create_in, open_dir
from whoosh.query import *

#creating the schema
schema = Schema(tax_id=STORED,
                name=TEXT(stored=True))

#creating the index
if not os.path.exists("index"):
    os.mkdir("index")

ix = create_in("index",schema)
ix = open_dir("index")
writer = ix.writer()
writer.add_document(tax_id="17",name=u"Methyliphilus methylitrophus")
writer.add_document(tax_id="17",name=u"Methylophilus methylotrophus Jenkins et al. 1987")
writer.add_document(tax_id="45",name=u"Chondromyces lichenicolus") 
writer.commit()

myquery = And([Term("name",u"Chondromyces")])
with ix.searcher() as searcher:
    print searcher.search(myquery)

Output:

<Top 0 Results for And([Term('name', u'Chondromyces lichenicolus')]) runtime=9.41753387451e-05>

Thanks!

  • 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-09T08:40:19+00:00Added an answer on June 9, 2026 at 8:40 am

    Was able to make it work

    from whoosh.qparser import QueryParser
    ix=open_dir("index")
    with ix.searcher() as searcher:
        query = QueryParser("name", ix.schema).parse(u'Chondromyces')
        results = searcher.search(query)
        for result in results:
            print result
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Benn trying to test a service layer method which returns a simple IList using
Want to write a typing test application (GUI, windows). Is simple terms. app shows
I'm wondering how people test artificial intelligence algorithms in an automated fashion. One example
I am trying to test code for simple comms with a serial device (at
Im Tyring to Delete all Files in E:. with wildcard. E:\test\*.txt I would ask
Trying to test selenium/webdriver, running ff8/fedora 13/64bit. Trying to do a simple test of
im trying to test example from developers webpage $token_url = https://graph.facebook.com/oauth/access_token? . client_id= .
trying to test out move semantics i build a simple class that allocates some
I'm trying to test the DB2 adapter for BizTalk 2006 (not R2). While trying
Trying to test deploy a simple Rails 3.1 app in production mode, using the

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.