Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I'm coding a Linux/PHP site for an organization. The site has two views, activated by a login $_SESSION variable indicating whether one is logged in as a member or not. I need to provide search functionality for both the public and for members. The members area is private. Note that Google Custom Search can't be used here in that case.

Does anyone have any recommendations on F/OSS scripts (or perhaps cheap scripts I can purchase) that would provide this functionality with two separate indices, one public and one private, and which would provide paginated results and a keyword search form?

Otherwise, I guess I'll have to code one myself. I'm trying to save time, and therefore keep more money in my pocket.


Note I can't ask this on StackOverflow because they want programmer questions there. This isn't a "how do I code this?" question, but "what F/OSS scripts or cheap sitescripts would solve this problem?" type of question.

Note also that this won't help me either. I mean, look at the answers of that question.

share|improve this question
I want to remain PHP. I may have to go custom. I'm thinking of using 'wget' to download the content, and use a secret ?member= code to activate being a member, so that I can get that content too. From the two folders of content, I can write a script to index this into SQLite. I can divide each page up into 3 parts, storing keywords for each, and this can help with relevancy algorithms with SELECT UNION. – Volomike May 23 '11 at 8:16

2 Answers 2

I've enjoyed using ElasticSearch, a Lucene-based, RESTful, schemaless JSON document search engine. While it is Java based, the simple RESTful interface is a breeze to use in PHP, and there's even a library to wrap the interface if you'd prefer yo use it. While it focuses on JSON data, it includes all of Lucene's fulltext goodness.

In your case, you would make the public/private nature of the content being searched an attribute in the document that you provide to the indexer. You can then simply include/exclude the attribute on searches when users are logged in/out as needed.

This is blindly assuming that your site is powered by some variety of database-backed CMS. ElasticSearch isn't a crawler, you have to manually provide it the JSON documents you want searched.

share|improve this answer

I would think (depending on the exact structure of your "Linux/PHP" site,) that you essentially have three main options.

Using an existing (non-PHP) IR/search system

You could (as suggested in @Charles's answer) use something like ElasticSearch, or host your own Lucene ( or Sphinx environment. Unfortunately, these solutions have some fairly hefty drawbacks (particularly if your site is somewhat small):

  1. You will need to provide these various engines with an index. Which may (depending on your application), be as simple as munging an RSS-feed of 'posts' or 'pages' etc. But it could also be fairly complex, if you have a large site with no underlying structure/DB to get index data from.

  2. These search engines will need to be hosted, either on a VPS, other server or (as with ElasticSearch) some SaaS platform. This would obviously add additional expense to your efforts.

Implement (or plug-in) a tag-based search

Tag based searching (ala SE), may be easier as it allows your users to construct the index for you. Whenever a member tags something, it gets added to a database which can then be searched for the member search. The obvious cons here are that:

  1. This burdens your users with the construction of the index, which may harm reliability, etc.

  2. Searching for tags and doing full text search are very different things. Your members may miss a lot of untagged results which may be relevant.

However, on the plus side this is probably cheaper than the first option, and may be quicker to implement than the next.

Roll-your-own crawler/spider to make an index

As you seem to be eluding to in your comment, you could use wget, curl or PHP's file_get_contents function to retrieve your own website's URL's (with some request flag or cookie to get member's area access). Although it may seem clunky (fetching your own content), this may be easier than constructing an index yourself if there's no underlying database or model for something like Lucene to use.

Once retrieved you then just need to tokenize the data and store it in something like a database or other form of index.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.