Tag:hadoop Superman college solr
| Using Java operations SOLR said a lot about SOLR's operations are directly on the page, the actual work is to use Java to operate, in this we see how to use Java to operate SOLRSOLR provides SOLRJ to use Java operation SOLR, SOLRJ is the encapsulation of 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 The following can write code, create a new TESTSOLR class, execute the time found error, Because of the lack of common-logging packages, add corresponding maven dependencies <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> &nbsP <version>1.1.1</version></dependency> In this case, you can print out the data in the Collection1 Index library, 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. Indexed index using the Add method, you can add a piece of data to SOLR. annotation mode indexing in practice, if it is difficult to set up a property for an attribute at the time of indexing, it is usually straightforward to use an object, and it is also 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 based on the ID or by the query criteria. Spell check spellcheck set the handler of the query, modified to/spell, get the query results, if the query result is 0, then no query to the results, it 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 can be obtained 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