| Using Java operations solr Many of the operations on SOLR are done directly on the page, and the actual work must be done using Java, Here we look at how Java is used to manipulate SOLRSOLR provides SOLRJ to use Java operations SOLR,SOLRJ is to encapsulate the HttpClient method to manipulate the SOLR API. First add maven dependency <dependency> <groupId>org.apache.solr</groupId> <artifactId>solr-solrj</artifactId> <version>4.10.4 </version></dependency> add junit4 maven dependencies <dependency> < groupid>junit</groupid> <artifactId>junit</artifactId> <version>4.12</version></dependency> Query queries you can write the code below and create a new TESTSOLR class, The error is found when executing, because of the lack of common-logging package, add corresponding maven dependency <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.1</version></dependency> This can be collection1 this index database inside the data printed out, because the query condition is *:* in this to pay attention to this baseurl, by default, if the operation Collection1 the data inside the words do not need to specify it, The Collection1 Index Library is manipulated by default. So the effect of the above two BaseURL is the same. Index using the Add method, you can add a piece of data to SOLR. Annotations How to build an index in the actual work, if it is difficult to set up a property for a property at the time of indexing, it is usually a direct use of an object, which is very convenient to use. First, create an entity class, focusing on the field in which you want to add an annotation, and if you don't add it, SOLR is not recognized. This allows the object to be indexed in SOLR. Deleting an index delete can be deleted by ID or by query criteria. spell Check spellcheck set the handler of the query, modify it to/spell, get the query results, if the query result is 0, then there is no query to the result, may be the input query keyword has an error, This allows the response of the spelling checker to be obtained based on the Getspellcheckresponse method, and the suggested results can be obtained based on some methods of this response. You can obtain the suggested results as follows. In this is the result obtained from the collation. Or get the suggested results based on the following method. In this is the result obtained from the suggestion. The results of the suggested spellings are available in both of the above ways. For more highlights, please pay attention to: http://bbs.superwu.cn attention to Superman academy QR Code: |
Java Operations SOLR implements indexes, queries, deletions, spell checking, and other functions