Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does solr4.7 build an index

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to build an index in solr4.7". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to build an index in solr4.7.

There are usually two ways for solr to build indexes:

1. Set the database connection in the configuration file and build the index directly

two。 Write a timer in the java program to build the index.

I use the latter because of the security and validity of the data processing.

Specific java code:

Public void testIndex () {try {List docs = new ArrayList (); SolrInputDocument doc = null; / / get data from the database DbUtilTest dbUtil = new DbUtilTest (); List list = new ArrayList (); list = dbUtil.query (); for (Map map: list) {/ / create document object doc = new SolrInputDocument (); doc.addField ("id", map.get ("id")) Doc.addField ("name", map.get ("name"); doc.addField ("author", map.get ("author")); doc.addField ("region", map.get ("region")); doc.addField ("theme", map.get ("theme")); doc.addField ("create_time", map.get ("create_time")); doc.addField ("content", map.get ("content")) Docs.add (doc);} / add server.add (docs); server.commit ();} catch (MalformedURLException e) {e.printStackTrace ();} catch (SolrServerException e) {e.printStackTrace ();} catch (IOException e) {e.printStackTrace ();}} so far, I believe you have a deeper understanding of "how to index solr4.7", so you might as well do it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report