You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Sudhanya Chatterjee <su...@persistent.co.in> on 2008/01/23 15:05:08 UTC

lucene.net query

Hi,

 

Using lucene.net we need to perform filtered search on xml files.

Filter should be on xml tags.

 

Example - 

 

If the XML files contains following kind of data - 

 

<?xml version="1.0"?>

<empID>10</empID>

<empName>Sudhanya</empName>

<empDept>Development</empDept>

 

 

For such a collection of XML files if I want to perform a search like-

            Find all employes where empDept = "Development"

 

How can I achieve this?

 

Thanks,

Sudhanya

 


DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.

RE: lucene.net query

Posted by DIGY <di...@gmail.com>.
Hi,

//While Indexing
Foreach xml file 
	Parse XMl File
	Document doc = new Document();
	Field f1 = new Field("empID", "10",
Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.UN_TOKENIZED);
	Field f2 = new Field("empName", "Sudhanya",
Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.TOKENIZED);
	Field f3 = new Field("empDept", "Development",
Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.UN_TOKENIZED);
	doc.Add(f1);
	doc.Add(f2);
	doc.Add(f3);
	indexWriter.AddDocument(doc);
EndForEach


//While Searching
Lucene.Net.QueryParsers.QueryParser qp = new
Lucene.Net.QueryParsers.QueryParser("empDept", new
Lucene.Net.Analysis.Standard.StandardAnalyzer());
Lucene.Net.Search.Query q = qp.Parse("Development");
Lucene.Net.Search.Hits hits = s.Search(q);

DIGY


-----Original Message-----
From: Sudhanya Chatterjee [mailto:sudhanya_chatterjee@persistent.co.in] 
Sent: Wednesday, January 23, 2008 4:05 PM
To: lucene-net-user@incubator.apache.org
Subject: lucene.net query

Hi,

 

Using lucene.net we need to perform filtered search on xml files.

Filter should be on xml tags.

 

Example - 

 

If the XML files contains following kind of data - 

 

<?xml version="1.0"?>

<empID>10</empID>

<empName>Sudhanya</empName>

<empDept>Development</empDept>

 

 

For such a collection of XML files if I want to perform a search like-

            Find all employes where empDept = "Development"

 

How can I achieve this?

 

Thanks,

Sudhanya

 


DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the
property of Persistent Systems Ltd. It is intended only for the use of the
individual or entity to which it is addressed. If you are not the intended
recipient, you are not authorized to read, retain, copy, print, distribute
or use this message. If you have received this communication in error,
please notify the sender and delete all copies of this message. Persistent
Systems Ltd. does not accept any liability for virus infected mails.