Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Edit: You can use Lucene. Here's an explanation how to do this in Lucene.net. Some Lucene basics are:</p> <ul> <li>Document - is the storage unit in Lucene. It is somewhat analogous to a database record.</li> <li>Field - the search unit in Lucene. Analogous to a database column. Lucene searches for text by taking a query and matching it against fields. A field should be indexed in order to enable search. </li> <li>Token - the search atom in Lucene. Usually a word, sometimes a phrase, letter or digit.</li> <li>Analyzer - the part of Lucene that transforms a field into tokens.</li> </ul> <p>Please read <a href="http://codeclimber.net.nz/archive/2009/09/02/lucene.net-your-first-application.aspx" rel="nofollow noreferrer">this blog post</a> about creating and using a Lucene.net index.</p> <p>I assume you are tagging blog posts. If I am totally wrong, please say so. In order to search for tags, you need to represent them as Lucene entities, namely as tokens inside a "tags" field.</p> <p>One way of doing so, is assigning a Lucene document per blog post. The document will have at least the following fields: </p> <ul> <li>id: unique id of the blog post.</li> <li>content: the text of the blog post.</li> <li>tags: list of tags.</li> </ul> <p>Indexing: Whenever you add a tag to a post, remove a tag or edit it, you will need to index the post. The Analyzer will transform the fields into their token representation. </p> <pre><code>Document doc = new Document(); doc.Add(new Field("id", i.ToString(), Field.Store.YES, Field.Index.NO)); doc.Add(new Field("content", text, Field.Store.YES, Field.Index.TOKENIZED)); doc.Add(new Field("tags", tags, Field.Store.YES, Field.Index.TOKENIZED)); writer.AddDocument(doc); </code></pre> <p>The remaining part is retrieval. For this, you need to create a <a href="http://incubator.apache.org/lucene.net/docs/2.4.1/Lucene.Net.QueryParsers.QueryParser.html" rel="nofollow noreferrer">QueryParser</a> and pass it a query string, like this:</p> <pre><code>QueryParser qp = new QueryParser(); Query q = qp.Parse(s); Hits = Searcher.Search(q); </code></pre> <p>The syntax you need for s will be:</p> <pre><code>tags: apples tags: carrots </code></pre> <p>To search for apples or carrots</p> <pre><code>tags: carrots NOT tags: apples </code></pre> <p>See the <a href="https://lucene.apache.org/core/2_9_4/queryparsersyntax.html" rel="nofollow noreferrer">Lucene Query Parser Syntax</a> for details on constructing s.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload