Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

Wikipedia Index

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


elshaimaa.ali at hotmail

Jun 19, 2012, 9:27 AM

Post #1 of 8 (489 views)
Permalink
Wikipedia Index

Hi everybody
I'm using Lucene3.6 to index Wikipedia documents which is over 3 million article, the data is on a mysql database and it is taking more than 24 hours so far.Do you know any tips that can speed up the indexing process
here is mycode:
public static void main(String[] args) { String indexPath = INDEXPATH; IndexWriter writer = null; DatabaseConfiguration dbConfig = new DatabaseConfiguration(); dbConfig.setHost(host); dbConfig.setDatabase(data); dbConfig.setUser(user); dbConfig.setPassword(password); dbConfig.setLanguage(Language.english);
try { Directory dir = FSDirectory.open(new File(indexPath)); Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_31); IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_31, analyzer); iwc.setOpenMode(OpenMode.CREATE); writer = new IndexWriter(dir, iwc); } catch (IOException e) { System.out.println(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } try { Wikipedia wiki = new Wikipedia(dbConfig); Iterable<Page> wikipages = wiki.getPages(); //get wikipedia articles from the database Iterator iter = wikipages.iterator(); while(iter.hasNext()){ Page p = (Page)iter.next(); System.out.println(p.getTitle().getPlainTitle()); Document doc = new Document(); Field contentField = new Field("contents", p.getPlainText(), Field.Store.NO, Field.Index.ANALYZED); Field titleField = new Field("title", p.getTitle().getPlainTitle(),Field.Store.YES, Field.Index.NOT_ANALYZED ); doc.add(contentField); // wiki page text doc.add(titleField); // wiki page title writer.addDocument(doc); } } catch (Exception e) { e.printStackTrace(); } }


lucene at mikemccandless

Jun 19, 2012, 1:29 PM

Post #2 of 8 (478 views)
Permalink
Re: Wikipedia Index [In reply to]

Likely the bottleneck is pulling content from the database? Maybe
test just that and see how long it takes?

24 hours is way too long to index all of Wikipedia. For example, we
index Wikipedia every night for our trunk/4.0 performance tests, here:

http://people.apache.org/~mikemccand/lucenebench/indexing.html

The export is a bit old now (01/15/2011) but it takes just under 6
minutes to fully index it. This is on a fairly beefy machine (24
cores)... and trunk/4.0 has substantial concurrency improvements over
3.x.

You can also try the ideas here:

http://wiki.apache.org/lucene-java/ImproveIndexingSpeed

Mike McCandless

http://blog.mikemccandless.com

On Tue, Jun 19, 2012 at 12:27 PM, Elshaimaa Ali
<elshaimaa.ali [at] hotmail> wrote:
>
> Hi everybody
> I'm using Lucene3.6 to index Wikipedia documents which is over 3 million article, the data is on a mysql database and it is taking more than 24 hours so far.Do you know any tips that can speed up the indexing process
> here is mycode:
> public static void main(String[] args) {             String indexPath = INDEXPATH;           IndexWriter writer = null;       DatabaseConfiguration dbConfig = new DatabaseConfiguration();           dbConfig.setHost(host);         dbConfig.setDatabase(data);             dbConfig.setUser(user);         dbConfig.setPassword(password);         dbConfig.setLanguage(Language.english);
>                  try {           Directory dir = FSDirectory.open(new File(indexPath));                  Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_31);        IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_31, analyzer);             iwc.setOpenMode(OpenMode.CREATE);       writer = new IndexWriter(dir, iwc);                         }               catch (IOException e) {                     System.out.println(" caught a " + e.getClass() +                 "\n with message: " + e.getMessage());               }                             try {                         Wikipedia wiki = new Wikipedia(dbConfig);                               Iterable<Page> wikipages = wiki.getPages(); //get wikipedia articles from the database                          Iterator iter = wikipages.iterator();                           while(iter.hasNext()){                          Page p = (Page)iter.next();                             System.out.println(p.getTitle().getPlainTitle());                                   Document doc = new Document();                                  Field contentField = new Field("contents", p.getPlainText(), Field.Store.NO, Field.Index.ANALYZED);                             Field titleField = new Field("title", p.getTitle().getPlainTitle(),Field.Store.YES, Field.Index.NOT_ANALYZED );                                 doc.add(contentField); // wiki page text                                doc.add(titleField); // wiki page title                                 writer.addDocument(doc);                            }                       } catch (Exception e) {                         e.printStackTrace();                    }                                 }
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


reynamelara at gmail

Jun 19, 2012, 2:26 PM

Post #3 of 8 (480 views)
Permalink
Re: Wikipedia Index [In reply to]

Could it be possible to index Wikipedia in a 2 core machine with 3 GB in
RAM? I have had the same problem trying to index it.

I've tried with a dump from april 2011.

Thanks
Reyna
CIC-IPN
Mexico

2012/6/19 Michael McCandless <lucene [at] mikemccandless>

> Likely the bottleneck is pulling content from the database? Maybe
> test just that and see how long it takes?
>
> 24 hours is way too long to index all of Wikipedia. For example, we
> index Wikipedia every night for our trunk/4.0 performance tests, here:
>
> http://people.apache.org/~mikemccand/lucenebench/indexing.html
>
> The export is a bit old now (01/15/2011) but it takes just under 6
> minutes to fully index it. This is on a fairly beefy machine (24
> cores)... and trunk/4.0 has substantial concurrency improvements over
> 3.x.
>
> You can also try the ideas here:
>
> http://wiki.apache.org/lucene-java/ImproveIndexingSpeed
>
> Mike McCandless
>
> http://blog.mikemccandless.com
>
> On Tue, Jun 19, 2012 at 12:27 PM, Elshaimaa Ali
> <elshaimaa.ali [at] hotmail> wrote:
> >
> > Hi everybody
> > I'm using Lucene3.6 to index Wikipedia documents which is over 3 million
> article, the data is on a mysql database and it is taking more than 24
> hours so far.Do you know any tips that can speed up the indexing process
> > here is mycode:
> > public static void main(String[] args) { String indexPath =
> INDEXPATH; IndexWriter writer = null; DatabaseConfiguration
> dbConfig = new DatabaseConfiguration(); dbConfig.setHost(host);
> dbConfig.setDatabase(data); dbConfig.setUser(user);
> dbConfig.setPassword(password);
> dbConfig.setLanguage(Language.english);
> > try { Directory dir = FSDirectory.open(new
> File(indexPath)); Analyzer analyzer = new
> StandardAnalyzer(Version.LUCENE_31); IndexWriterConfig iwc = new
> IndexWriterConfig(Version.LUCENE_31, analyzer);
> iwc.setOpenMode(OpenMode.CREATE); writer = new IndexWriter(dir, iwc);
> } catch (IOException e) {
> System.out.println(" caught a " + e.getClass() +
> "\n with message: " + e.getMessage()); }
> try { Wikipedia wiki = new
> Wikipedia(dbConfig); Iterable<Page> wikipages
> = wiki.getPages(); //get wikipedia articles from the database
> Iterator iter = wikipages.iterator();
> while(iter.hasNext()){ Page p = (Page)iter.next();
>
> System.out.println(p.getTitle().getPlainTitle());
> Document doc = new Document();
> Field contentField = new Field("contents", p.getPlainText(),
> Field.Store.NO, Field.Index.ANALYZED); Field
> titleField = new Field("title",
> p.getTitle().getPlainTitle(),Field.Store.YES, Field.Index.NOT_ANALYZED );
> doc.add(contentField); // wiki page text
> doc.add(titleField); // wiki page title
> writer.addDocument(doc);
> } } catch (Exception e) {
> e.printStackTrace(); } }
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>
>


--
Reyna


elshaimaa.ali at hotmail

Jun 19, 2012, 3:27 PM

Post #4 of 8 (477 views)
Permalink
RE: Wikipedia Index [In reply to]

Thanks Mike for the prompt replyDo you have a fully indexed version of the wikipedia, I mainly need two fields for each document the indexed content of the wikipedia articles and the title.if there is any place where I can get the index, that will save me great time
regardsshaimaa

> From: lucene [at] mikemccandless
> Date: Tue, 19 Jun 2012 16:29:39 -0400
> Subject: Re: Wikipedia Index
> To: java-user [at] lucene
>
> Likely the bottleneck is pulling content from the database? Maybe
> test just that and see how long it takes?
>
> 24 hours is way too long to index all of Wikipedia. For example, we
> index Wikipedia every night for our trunk/4.0 performance tests, here:
>
> http://people.apache.org/~mikemccand/lucenebench/indexing.html
>
> The export is a bit old now (01/15/2011) but it takes just under 6
> minutes to fully index it. This is on a fairly beefy machine (24
> cores)... and trunk/4.0 has substantial concurrency improvements over
> 3.x.
>
> You can also try the ideas here:
>
> http://wiki.apache.org/lucene-java/ImproveIndexingSpeed
>
> Mike McCandless
>
> http://blog.mikemccandless.com
>
> On Tue, Jun 19, 2012 at 12:27 PM, Elshaimaa Ali
> <elshaimaa.ali [at] hotmail> wrote:
> >
> > Hi everybody
> > I'm using Lucene3.6 to index Wikipedia documents which is over 3 million article, the data is on a mysql database and it is taking more than 24 hours so far.Do you know any tips that can speed up the indexing process
> > here is mycode:
> > public static void main(String[] args) { á á á á á á String indexPath = INDEXPATH; á á á á á IndexWriter writer = null; á á á DatabaseConfiguration dbConfig = new DatabaseConfiguration(); á á á á á dbConfig.setHost(host); á á á á dbConfig.setDatabase(data); á á á á á á dbConfig.setUser(user); á á á á dbConfig.setPassword(password); á á á á dbConfig.setLanguage(Language.english);
> > á á á á á á á á átry { á á á á á Directory dir = FSDirectory.open(new File(indexPath)); á á á á á á á á áAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_31); á á á áIndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_31, analyzer); á á á á á á iwc.setOpenMode(OpenMode.CREATE); á á á writer = new IndexWriter(dir, iwc); á á á á á á á á á á á á } á á á á á á á catch (IOException e) { á á á á á á á á á á System.out.println(" caught a " + e.getClass() + á á á á á á á á "\n with message: " + e.getMessage()); á á á á á á á } á á á á á á á á á á á á á á try { á á á á á á á á á á á á Wikipedia wiki = new Wikipedia(dbConfig); á á á á á á á á á á á á á á á Iterable<Page> wikipages = wiki.getPages(); //get wikipedia articles from the database á á á á á á á á á á á á áIterator iter = wikipages.iterator(); á á á á á á á á á á á á á while(iter.hasNext()){ á á á á á á á á á á á á áPage p = (Page)iter.next(); á á á á á á á á á á á á á á System.out.println(p.getTitle().getPlainTitle()); á á á á á á á á á á á á á á á á á Document doc = new Document(); á á á á á á á á á á á á á á á á áField contentField = new Field("contents", p.getPlainText(), Field.Store.NO, Field.Index.ANALYZED); á á á á á á á á á á á á á á Field titleField = new Field("title", p.getTitle().getPlainTitle(),Field.Store.YES, Field.Index.NOT_ANALYZED ); á á á á á á á á á á á á á á á á doc.add(contentField); // wiki page text á á á á á á á á á á á á á á á ádoc.add(titleField); // wiki page title á á á á á á á á á á á á á á á á writer.addDocument(doc); á á á á á á á á á á á á á á} á á á á á á á á á á á } catch (Exception e) { á á á á á á á á á á á á e.printStackTrace(); á á á á á á á á á á} á á á á á á á á á á á á á á á á }
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>


lucene at mikemccandless

Jun 19, 2012, 4:45 PM

Post #5 of 8 (478 views)
Permalink
Re: Wikipedia Index [In reply to]

3 GB RAM is plenty for indexing Wikipedia (eg, that nightly benchmark
uses a 2 GB heap).

2 cores just means it'll take longer than more cores... just use 2
indexing threads.

Mike McCandless

http://blog.mikemccandless.com

On Tue, Jun 19, 2012 at 5:26 PM, Reyna Melara <reynamelara [at] gmail> wrote:
> Could it be possible to index Wikipedia in a 2 core machine with 3 GB in
> RAM? I have had the same problem trying to index it.
>
> I've tried with a dump from april 2011.
>
> Thanks
> Reyna
> CIC-IPN
> Mexico
>
> 2012/6/19 Michael McCandless <lucene [at] mikemccandless>
>
>> Likely the bottleneck is pulling content from the database?  Maybe
>> test just that and see how long it takes?
>>
>> 24 hours is way too long to index all of Wikipedia.  For example, we
>> index Wikipedia every night for our trunk/4.0 performance tests, here:
>>
>>    http://people.apache.org/~mikemccand/lucenebench/indexing.html
>>
>> The export is a bit old now (01/15/2011) but it takes just under 6
>> minutes to fully index it.  This is on a fairly beefy machine (24
>> cores)... and trunk/4.0 has substantial concurrency improvements over
>> 3.x.
>>
>> You can also try the ideas here:
>>
>>    http://wiki.apache.org/lucene-java/ImproveIndexingSpeed
>>
>> Mike McCandless
>>
>> http://blog.mikemccandless.com
>>
>> On Tue, Jun 19, 2012 at 12:27 PM, Elshaimaa Ali
>> <elshaimaa.ali [at] hotmail> wrote:
>> >
>> > Hi everybody
>> > I'm using Lucene3.6 to index Wikipedia documents which is over 3 million
>> article, the data is on a mysql database and it is taking more than 24
>> hours so far.Do you know any tips that can speed up the indexing process
>> > here is mycode:
>> > public static void main(String[] args) {             String indexPath =
>> INDEXPATH;           IndexWriter writer = null;       DatabaseConfiguration
>> dbConfig = new DatabaseConfiguration();           dbConfig.setHost(host);
>>       dbConfig.setDatabase(data);             dbConfig.setUser(user);
>>   dbConfig.setPassword(password);
>> dbConfig.setLanguage(Language.english);
>> >                  try {           Directory dir = FSDirectory.open(new
>> File(indexPath));                  Analyzer analyzer = new
>> StandardAnalyzer(Version.LUCENE_31);        IndexWriterConfig iwc = new
>> IndexWriterConfig(Version.LUCENE_31, analyzer);
>> iwc.setOpenMode(OpenMode.CREATE);       writer = new IndexWriter(dir, iwc);
>>                         }               catch (IOException e) {
>>         System.out.println(" caught a " + e.getClass() +
>> "\n with message: " + e.getMessage());               }
>>         try {                         Wikipedia wiki = new
>> Wikipedia(dbConfig);                               Iterable<Page> wikipages
>> = wiki.getPages(); //get wikipedia articles from the database
>>            Iterator iter = wikipages.iterator();
>> while(iter.hasNext()){                          Page p = (Page)iter.next();
>>
>> System.out.println(p.getTitle().getPlainTitle());
>>         Document doc = new Document();
>>  Field contentField = new Field("contents", p.getPlainText(),
>> Field.Store.NO, Field.Index.ANALYZED);                             Field
>> titleField = new Field("title",
>> p.getTitle().getPlainTitle(),Field.Store.YES, Field.Index.NOT_ANALYZED );
>>                               doc.add(contentField); // wiki page text
>>                            doc.add(titleField); // wiki page title
>>                         writer.addDocument(doc);
>>  }                       } catch (Exception e) {
>> e.printStackTrace();                    }                                 }
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
>> For additional commands, e-mail: java-user-help [at] lucene
>>
>>
>
>
> --
> Reyna

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


lucene at mikemccandless

Jun 19, 2012, 4:48 PM

Post #6 of 8 (476 views)
Permalink
Re: Wikipedia Index [In reply to]

I have the index locally ... but it's really impractical to send it
especially if you already have the source text locally.

Maybe index directly from the source text instead of via a database?
Lucene's benchmark contrib/module has code to decode the XML into
documents...

Mike McCandless

http://blog.mikemccandless.com

On Tue, Jun 19, 2012 at 6:27 PM, Elshaimaa Ali
<elshaimaa.ali [at] hotmail> wrote:
>
> Thanks Mike for the prompt replyDo you have a fully indexed version of the wikipedia,  I mainly need two fields for each document the indexed content of the wikipedia articles  and the title.if there is any place where I can get the index, that will save me great time
> regardsshaimaa
>
>> From: lucene [at] mikemccandless
>> Date: Tue, 19 Jun 2012 16:29:39 -0400
>> Subject: Re: Wikipedia Index
>> To: java-user [at] lucene
>>
>> Likely the bottleneck is pulling content from the database?  Maybe
>> test just that and see how long it takes?
>>
>> 24 hours is way too long to index all of Wikipedia.  For example, we
>> index Wikipedia every night for our trunk/4.0 performance tests, here:
>>
>>     http://people.apache.org/~mikemccand/lucenebench/indexing.html
>>
>> The export is a bit old now (01/15/2011) but it takes just under 6
>> minutes to fully index it.  This is on a fairly beefy machine (24
>> cores)... and trunk/4.0 has substantial concurrency improvements over
>> 3.x.
>>
>> You can also try the ideas here:
>>
>>     http://wiki.apache.org/lucene-java/ImproveIndexingSpeed
>>
>> Mike McCandless
>>
>> http://blog.mikemccandless.com
>>
>> On Tue, Jun 19, 2012 at 12:27 PM, Elshaimaa Ali
>> <elshaimaa.ali [at] hotmail> wrote:
>> >
>> > Hi everybody
>> > I'm using Lucene3.6 to index Wikipedia documents which is over 3 million article, the data is on a mysql database and it is taking more than 24 hours so far.Do you know any tips that can speed up the indexing process
>> > here is mycode:
>> > public static void main(String[] args) { á á á á á á String indexPath = INDEXPATH; á á á á á IndexWriter writer = null; á á á DatabaseConfiguration dbConfig = new DatabaseConfiguration(); á á á á á dbConfig.setHost(host); á á á á dbConfig.setDatabase(data); á á á á á á dbConfig.setUser(user); á á á á dbConfig.setPassword(password); á á á á dbConfig.setLanguage(Language.english);
>> > á á á á á á á á átry { á á á á á Directory dir = FSDirectory.open(new File(indexPath)); á á á á á á á á áAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_31); á á á áIndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_31, analyzer); á á á á á á iwc.setOpenMode(OpenMode.CREATE); á á á writer = new IndexWriter(dir, iwc); á á á á á á á á á á á á } á á á á á á á catch (IOException e) { á á á á á á á á á á System.out.println(" caught a " + e.getClass() + á á á á á á á á "\n with message: " + e.getMessage()); á á á á á á á } á á á á á á á á á á á á á á try { á á á á á á á á á á á á Wikipedia wiki = new Wikipedia(dbConfig); á á á á á á á á á á á á á á á Iterable<Page> wikipages = wiki.getPages(); //get wikipedia articles from the database á á á á á á á á á á á á áIterator iter = wikipages.iterator(); á á á á á á á á á á á á á while(iter.hasNext()){ á á á á á á á á á á á á áPage p = (Page)iter.next(); á á á á á á á á á á á á á á System.out.println(p.getTitle().getPlainTitle()); á á á á á á á á á á á á á á á á á Document doc = new Document(); á á á á á á á á á á á á á á á á áField contentField = new Field("contents", p.getPlainText(), Field.Store.NO, Field.Index.ANALYZED); á á á á á á á á á á á á á á Field titleField = new Field("title", p.getTitle().getPlainTitle(),Field.Store.YES, Field.Index.NOT_ANALYZED ); á á á á á á á á á á á á á á á á doc.add(contentField); // wiki page text á á á á á á á á á á á á á á á ádoc.add(titleField); // wiki page title á á á á á á á á á á á á á á á á writer.addDocument(doc); á á á á á á á á á á á á á á} á á á á á á á á á á á } catch (Exception e) { á á á á á á á á á á á á e.printStackTrace(); á á á á á á á á á á} á á á á á á á á á á á á á á á á }
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
>> For additional commands, e-mail: java-user-help [at] lucene
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


elshaimaa.ali at hotmail

Jun 19, 2012, 5:03 PM

Post #7 of 8 (476 views)
Permalink
RE: Wikipedia Index [In reply to]

I only have the source text on a mysql database
Do you know where I can download it in xml and is it possible to split the documents into content and title
thanksshaimaa
> From: lucene [at] mikemccandless
> Date: Tue, 19 Jun 2012 19:48:24 -0400
> Subject: Re: Wikipedia Index
> To: java-user [at] lucene
>
> I have the index locally ... but it's really impractical to send it
> especially if you already have the source text locally.
>
> Maybe index directly from the source text instead of via a database?
> Lucene's benchmark contrib/module has code to decode the XML into
> documents...
>
> Mike McCandless
>
> http://blog.mikemccandless.com
>
> On Tue, Jun 19, 2012 at 6:27 PM, Elshaimaa Ali
> <elshaimaa.ali [at] hotmail> wrote:
> >
> > Thanks Mike for the prompt replyDo you have a fully indexed version of the wikipedia, I mainly need two fields for each document the indexed content of the wikipedia articles and the title.if there is any place where I can get the index, that will save me great time
> > regardsshaimaa
> >
> >> From: lucene [at] mikemccandless
> >> Date: Tue, 19 Jun 2012 16:29:39 -0400
> >> Subject: Re: Wikipedia Index
> >> To: java-user [at] lucene
> >>
> >> Likely the bottleneck is pulling content from the database? Maybe
> >> test just that and see how long it takes?
> >>
> >> 24 hours is way too long to index all of Wikipedia. For example, we
> >> index Wikipedia every night for our trunk/4.0 performance tests, here:
> >>
> >> http://people.apache.org/~mikemccand/lucenebench/indexing.html
> >>
> >> The export is a bit old now (01/15/2011) but it takes just under 6
> >> minutes to fully index it. This is on a fairly beefy machine (24
> >> cores)... and trunk/4.0 has substantial concurrency improvements over
> >> 3.x.
> >>
> >> You can also try the ideas here:
> >>
> >> http://wiki.apache.org/lucene-java/ImproveIndexingSpeed
> >>
> >> Mike McCandless
> >>
> >> http://blog.mikemccandless.com
> >>
> >> On Tue, Jun 19, 2012 at 12:27 PM, Elshaimaa Ali
> >> <elshaimaa.ali [at] hotmail> wrote:
> >> >
> >> > Hi everybody
> >> > I'm using Lucene3.6 to index Wikipedia documents which is over 3 million article, the data is on a mysql database and it is taking more than 24 hours so far.Do you know any tips that can speed up the indexing process
> >> > here is mycode:
> >> > public static void main(String[] args) { á á á á á á String indexPath = INDEXPATH; á á á á á IndexWriter writer = null; á á á DatabaseConfiguration dbConfig = new DatabaseConfiguration(); á á á á á dbConfig.setHost(host); á á á á dbConfig.setDatabase(data); á á á á á á dbConfig.setUser(user); á á á á dbConfig.setPassword(password); á á á á dbConfig.setLanguage(Language.english);
> >> > á á á á á á á á átry { á á á á á Directory dir = FSDirectory.open(new File(indexPath)); á á á á á á á á áAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_31); á á á áIndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_31, analyzer); á á á á á á iwc.setOpenMode(OpenMode.CREATE); á á á writer = new IndexWriter(dir, iwc); á á á á á á á á á á á á } á á á á á á á catch (IOException e) { á á á á á á á á á á System.out.println(" caught a " + e.getClass() + á á á á á á á á "\n with message: " + e.getMessage()); á á á á á á á } á á á á á á á á á á á á á á try { á á á á á á á á á á á á Wikipedia wiki = new Wikipedia(dbConfig); á á á á á á á á á á á á á á á Iterable<Page> wikipages = wiki.getPages(); //get wikipedia articles from the database á á á á á á á á á á á á áIterator iter = wikipages.iterator(); á á á á á á á á á á á á á while(iter.hasNext()){ á á á á á á á á á á á á áPage p = (Page)iter.next(); á á á á á á á á á á á á á á System.out.println(p.getTitle().getPlainTitle()); á á á á á á á á á á á á á á á á á Document doc = new Document(); á á á á á á á á á á á á á á á á áField contentField = new Field("contents", p.getPlainText(), Field.Store.NO, Field.Index.ANALYZED); á á á á á á á á á á á á á á Field titleField = new Field("title", p.getTitle().getPlainTitle(),Field.Store.YES, Field.Index.NOT_ANALYZED ); á á á á á á á á á á á á á á á á doc.add(contentField); // wiki page text á á á á á á á á á á á á á á á ádoc.add(titleField); // wiki page title á á á á á á á á á á á á á á á á writer.addDocument(doc); á á á á á á á á á á á á á á} á á á á á á á á á á á } catch (Exception e) { á á á á á á á á á á á á e.printStackTrace(); á á á á á á á á á á} á á á á á á á á á á á á á á á á }
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
> >> For additional commands, e-mail: java-user-help [at] lucene
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>


gbowyer at shopzilla

Jun 19, 2012, 5:42 PM

Post #8 of 8 (478 views)
Permalink
Re: Wikipedia Index [In reply to]

It depends on what you want, but the wikipedia data dumps can be found here

http://en.wikipedia.org/wiki/Wikipedia:Database_download

On 19/06/12 17:03, Elshaimaa Ali wrote:
> I only have the source text on a mysql database
> Do you know where I can download it in xml and is it possible to split the documents into content and title
> thanksshaimaa
>> From: lucene [at] mikemccandless
>> Date: Tue, 19 Jun 2012 19:48:24 -0400
>> Subject: Re: Wikipedia Index
>> To: java-user [at] lucene
>>
>> I have the index locally ... but it's really impractical to send it
>> especially if you already have the source text locally.
>>
>> Maybe index directly from the source text instead of via a database?
>> Lucene's benchmark contrib/module has code to decode the XML into
>> documents...
>>
>> Mike McCandless
>>
>> http://blog.mikemccandless.com
>>
>> On Tue, Jun 19, 2012 at 6:27 PM, Elshaimaa Ali
>> <elshaimaa.ali [at] hotmail> wrote:
>>> Thanks Mike for the prompt replyDo you have a fully indexed version of the wikipedia, I mainly need two fields for each document the indexed content of the wikipedia articles and the title.if there is any place where I can get the index, that will save me great time
>>> regardsshaimaa
>>>
>>>> From: lucene [at] mikemccandless
>>>> Date: Tue, 19 Jun 2012 16:29:39 -0400
>>>> Subject: Re: Wikipedia Index
>>>> To: java-user [at] lucene
>>>>
>>>> Likely the bottleneck is pulling content from the database? Maybe
>>>> test just that and see how long it takes?
>>>>
>>>> 24 hours is way too long to index all of Wikipedia. For example, we
>>>> index Wikipedia every night for our trunk/4.0 performance tests, here:
>>>>
>>>> http://people.apache.org/~mikemccand/lucenebench/indexing.html
>>>>
>>>> The export is a bit old now (01/15/2011) but it takes just under 6
>>>> minutes to fully index it. This is on a fairly beefy machine (24
>>>> cores)... and trunk/4.0 has substantial concurrency improvements over
>>>> 3.x.
>>>>
>>>> You can also try the ideas here:
>>>>
>>>> http://wiki.apache.org/lucene-java/ImproveIndexingSpeed
>>>>
>>>> Mike McCandless
>>>>
>>>> http://blog.mikemccandless.com
>>>>
>>>> On Tue, Jun 19, 2012 at 12:27 PM, Elshaimaa Ali
>>>> <elshaimaa.ali [at] hotmail> wrote:
>>>>> Hi everybody
>>>>> I'm using Lucene3.6 to index Wikipedia documents which is over 3 million article, the data is on a mysql database and it is taking more than 24 hours so far.Do you know any tips that can speed up the indexing process
>>>>> here is mycode:
>>>>> public static void main(String[] args) { á á á á á á String indexPath = INDEXPATH; á á á á á IndexWriter writer = null; á á á DatabaseConfiguration dbConfig = new DatabaseConfiguration(); á á á á á dbConfig.setHost(host); á á á á dbConfig.setDatabase(data); á á á á á á dbConfig.setUser(user); á á á á dbConfig.setPassword(password); á á á á dbConfig.setLanguage(Language.english);
>>>>> á á á á á á á á átry { á á á á á Directory dir = FSDirectory.open(new File(indexPath)); á á á á á á á á áAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_31); á á á áIndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_31, analyzer); á á á á á á iwc.setOpenMode(OpenMode.CREATE); á á á writer = new IndexWriter(dir, iwc); á á á á á á á á á á á á } á á á á á á á catch (IOException e) { á á á á á á á á á á System.out.println(" caught a " + e.getClass() + á á á á á á á á "\n with message: " + e.getMessage()); á á á á á á á } á á á á á á á á á á á á á á try { á á á á á á á á á á á á Wikipedia wiki = new Wikipedia(dbConfig); á á á á á á á á á á á á á á á Iterable<Page> wikipages = wiki.getPages(); //get wikipedia articles from the database á á á á á á á á á á á á áIterator iter = wikipages.iterator(); á á á á á á á á á á á á á while(iter.hasNext()){ á á á á á á á á á á á á áPage p = (Page)iter.next(); á á á á á á á á á á á á á á System.out.println(p.getTitle().getPlainTitle()); á á á á á á á á á á á á á á á á á Document doc = new Document(); á á á á á á á á á á á á á á á á áField contentField = new Field("contents", p.getPlainText(), Field.Store.NO, Field.Index.ANALYZED); á á á á á á á á á á á á á á Field titleField = new Field("title", p.getTitle().getPlainTitle(),Field.Store.YES, Field.Index.NOT_ANALYZED ); á á á á á á á á á á á á á á á á doc.add(contentField); // wiki page text á á á á á á á á á á á á á á á ádoc.add(titleField); // wiki page title á á á á á á á á á á á á á á á á writer.addDocument(doc); á á á á á á á á á á á á á á} á á á á á á á á á á á } catch (Exception e) { á á á á á á á á á á á á e.printStackTrace(); á á á á á á á á á á} á á á á á á á á á á á á á á á á }
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
>>>> For additional commands, e-mail: java-user-help [at] lucene
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
>> For additional commands, e-mail: java-user-help [at] lucene
>>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.