Using roo I have generated following spring bean
<bean class="org.apache.solr.client.solrj.impl.CommonsHttpSolrServer" id="solrServer">
<constructor-arg value="${solr.serverUrl}"/>
</bean>
Config file has
solr.serverUrl=http\://localhost\:8983/solr
which is used as follows:
@Autowired
transient SolrServer Address.solrServer;
@Async
public static void Address.indexAddresses(Collection<Address> addresses) {
List<SolrInputDocument> documents = new ArrayList<SolrInputDocument>();
for (Address address : addresses) {
SolrInputDocument sid = new SolrInputDocument();
sid.addField("id", "address_" + address.getId());
sid.addField("address.id_i", address.getId());
// Add summary field to allow searching documents for objects of this type
sid.addField("address_solrsummary_t", new StringBuilder().append(address.getId()));
documents.add(sid);
}
try {
SolrServer solrServer = solrServer();
solrServer.add(documents);
solrServer.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
My question is:
Do I have to create schema in solr in order to index it in solr or this code is good enough?
Apart from this my application is a multi tier architecture and website is a small part in it. So how could I delete the data which is deleted by lets say windows application or android application.
One solution could be recreate the index but wouldn’t it result in lose of stats in solr which is used to make the search result more effective(which I am not sure of)?
How could I add synonym search in solr and how could I initialize spelling mistake add-on (words could be name of a person or place basically not from dictionary)?
Sorry for merging multiple questions. Thanks in advance for your help.
Yes you should have schema.xml file and you should define the fields there to index.
You can delete the document using the following code snippet. Assuming the there is a field id which has a value 12345. You can write your query between the
<query>tags.AFAIK, search stats are not saved by default, so re-creating index could be a solution.
You can add SynonymFilterFactory to the field definition in the schema.xml file.