Package COM.JADYER.SOLRJ;
Import java.util.ArrayList;
Import java.util.List;
Import Org.apache.solr.client.solrj.SolrQuery;
Import Org.apache.solr.client.solrj.SolrServer;
Import org.apache.solr.client.solrj.SolrServerException;
Import Org.apache.solr.client.solrj.impl.HttpSolrServer;
Import Org.apache.solr.client.solrj.response.QueryResponse;
Import org.apache.solr.common.SolrDocument;
Import org.apache.solr.common.SolrDocumentList;
Import org.apache.solr.common.SolrInputDocument;
Import Com.jadyer.model.MyMessage; /** * "Lucene3.6.2 Introductory Series" section 14th _SOLRJ Operation index and search documents, and integrate Chinese participle * @see---------------------------------------------------- ---------------------------------------------------------------------* @see to integrate SOLR with Chinese participle through schema.xml * @se e 0) The default SOLR definition of a large number of domains do not support Chinese participle, if we want to add Chinese participle support, then the first thing to add is <types><fieldType/></types> * @see below with Mmseg4j-1.8.5, for example, describes the way in which SOLR and Chinese word breakers are integrated (the core of which is to configure FieldType in Schema.xml) * @see about mmseg4j, as described in http://blog.csdn.net/jadyer/ article/details/10049525 * @see 1) copy Mmseg4j-all-1.8.5.jar to D:\Develop\apache-solr-3.6.2\server\solr\WEB-INF\lib\ Folder * @see 2) New D:\Develop\apache-solr-3.6.2\home\dic\ folder * @see 3) copies the dictionary files from the Mmseg4j-1.8.5.zip\data\ folder to the D:\Deve Lop\apache-solr-3.6.2\home\dic\ * @see 4) Add the FieldType definition of Chinese word segmentation in Schame.xml * @see usually Chinese word segmentation in the Toolkit will provide README.txt files, The face describes the FieldType * that needs to be configured to extend SOLR @see empathy opens the README.txt in Mmseg4j-1.8.5.zip and copies the three FieldType that are described in the copy to the 68th line of the schema.xml * @se E 5 Confirm and modify the Dicpath property value of "dic" in these three filetype (dic in fact refers to the second step of the new DIC folder) * @see 6) Finally test the Chinese word segmentation effect * @see on the SOLR console (http ://127.0.0.1:8088/solr/admin/) Click on the blue Bold [analysis] * @see then modify the field drop-down box to type under field analysis and enter text_general in the right text box (that is, Schema.xml defined in fieldtype) * @see then enter the test text in the text box to the right of field Value (Index) ' I'm from Bayan County, Xinglong Town Changchun Villagers ' Rights village,, Harbin, Heilongjiang Province, China ' * @see click again Below the Analyze button, we'll find Text_generaL of the word situation, and then we modify text_general for just a custom textcomplex, see the effect of the * @see can also be checked to select the field Value (Index) below the verbose output marquee, which will also be participle of the Attributes (Position,offset,type, etc.) are displayed together * @see------------------------------------------------------------------------
-------------------------------------------------* @see in this case, 9 jars are aggregated, as shown below * @see Apache-solr-core-3.6.2.jar * @see Apache-solr-solrj-3.6.2.jar * @see Commons-codec-1.6.jar * @see Commons-io-2.1.jar * @see
Httpclient-4.1.3.jar * @see Httpcore-4.1.4.jar * @see Httpmime-4.1.3.jar * @see Jcl-over-slf4j-1.6.1.jar * @see Slf4j-api-1.6.1.jar * @see--------------------------------------------------------------------------- ----------------------------------------------* @create Aug 7, 2013 11:06:20 PM * @author Xuan Yu
And finally, a little test written by junit4.x.
Package com.jadyer.test;
Import Org.junit.Test;
Import Com.jadyer.solrj.HelloSolrJ;
public class Hellosolrjtest {
@Test public
void Deleteallindex () {
HelloSolrJ.INSTANCE.deleteAllIndex ();
}
@Test public
void Addindexandsearchfile () {
HelloSolrJ.INSTANCE.addIndex ();
HelloSolrJ.INSTANCE.searchFile ();
}
@Test public
void Addindexandsearchfilebybean () {
HelloSolrJ.INSTANCE.addIndexByBean ();
HelloSolrJ.INSTANCE.searchFileByBean ();
}