Is there a way to call solrs analysis api in java using solr-core and get the analyzed tokens.
Analysis api takes fieldName or fieldType and values and give the analyzed tokens.
Is there a way to get those tokens from java?
I found the following link: FieldAnalysisRequestHandler, But I could not get any examples to use it.
In the Admin UI (for which the FieldAnalysisRequestHandler is meant) you can call it by selecting a core and then go to the "Analysis" entry.
See https://cwiki.apache.org/confluence/x/UYDxAQ or https://cwiki.apache.org/confluence/x/FoDxAQ for that.
From a client (which I guess you mean, as you tagged this question with solrj) you need to call the correct URL.
Typically the FieldAnalysisRequestHandler is bound to /analysis/field, see your solrconfig.xml.
From Solrj it should work like this:
SolrQuery query = new SolrQuery();
solrQuery.setRequestHandler("/analysis/field");
solrQuery.set("analysis.fieldtype", "mytype");
solrQuery.set("analysis.fieldvalue", "myval");
QueryResponse solrResponse = solrServer.query(solrQuery);
But it doesn't seem like there's a great support for this in Solrj, probably because it's meant to be called from the Solr Admin UI as mentioned.
Related
I have am currently running through some queries using the Java API provided by MarkLogic. I have installed it through adding the required dependencies to my library. The connection is set up using
DatabaseClient client = DatabaseClientFactory.newClient("localhost", 8000, secContext, ConnectionType.DIRECT);
From here some XQueries are ran using the code shown below
ServerEvaluationCall evl = client.newServerEval().xquery(query);
EvalResultIterator evr = evl.eval();
while(evr.hasNext()){
//Do something with the results
}
However, certain queries takes a long time to process causing an internal error.So Other then reducing the query time required, I am wondering if there is there a way to overcome this? Such as increasing of connection time limit for instance.
====Update===
Query used
xquery version "1.0-ml";
let $query-opts := /comments[fn:matches(text,".*generation.*")]
return(
$query-opts, fn:count($query-opts), xdmp:elapsed-time()
)
I know the regular expression used can be easily replaced by word-query. But for this instance I would like to just used regular expression for searching.
Example Data
<comments>
<date_commented>1998-01-14T04:32:30</date_commented>
<text>iCloud sync settings are not supposed to change after an iOS update. In the case of iOS 10.3 this was due to a bug.</text>
<uri>/comment/000000001415898</uri>
</comments>
On the basis of your provided data I'd use xdmp:estimate and a cts query.
xdmp:estimate(cts:search(doc(), cts:and-query((
cts:directory-query('/comment/'),
cts:element-word-query(xs:QName("text"), "generation")
))))
This will search all documents in your /comments/ directory for an element text containing the word generation. As you already know, this will only use indexes and does not require loading/parsing documents.
This also will not find any false-positives because there is only one text element per document/fragment (if your shown data is correct).
There are some samples on http://www.mybatis.org/mybatis-dynamic-sql/docs/select.html.
I want to implement limit/offset for mysql but failed to see any document on describing how to extend this library to support additional where condition.
here is what i'd like to achieve:
SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
.from(animalData)
.where(id, isIn(1, 5, 7))
.and(bodyWeight, isBetween(1.0).and(3.0))
.orderBy(id.descending(), bodyWeight)
.limit(1).offset(10)
.build()
.render(RenderingStrategy.MYBATIS3);
There are a couple of resources you can use.
This page - http://www.mybatis.org/mybatis-dynamic-sql/docs/whereClauses.html - shows an example of using standalone where clauses to build a paging query. This is not exactly what you are looking for, but it shows one way to do it.
There is a unit test showing something that is closer to what you are looking for here - https://github.com/mybatis/mybatis-dynamic-sql/tree/master/src/test/java/examples/paging. This code works for MySQL and you could use it as is.
I hope to make this a little easier in a future release.
I've updated to elasticsearch java library version 5.2.0.
In 2.x,
I was using SearchRequestBuilder.addField() in order to add a field to the search request. Nevertheless, It seems to be replaced. I've written the available methods intellisense is showing me. Which of them do I need to pick?
addDocValueField
addFieldDataField
addScriptField
addStoredField
storedFields
fields
SearchRequestBuilder.setNoFields is also removed. Which would be the alternative?
Currently, I'm calling scripts from Java using this code. Is there any more elegant way to call it in 5.x Java API?
Code:
return AggregationBuilders
.terms(this.getName())
.field(this.getName())
.script(new Script(
ScriptType.FILE,
"painless",
"year",
ImmutableMap.of("field", this.getName())
)
);
As you can see I setting field as script parameter. Nevertheless, I don't quite understand how to get it from script code.
Thanks.
When in doubt, go to the source
use setFetchSource(String[] includes, String[] excludes) instead
use setFetchSource(false) instead
if you need to execute this script for each document, you can use addScriptField()
I am making a call from a server that is located in US to FindItemsAdvanced of ebay finding api.
I define ListedIn as "EBAY-ENCA", however, when I make the call - I see that it doesn't return results. I believe that this is because that items are not available to US.
I see that there is a parameter called: AvailableTo - but how can I say "to all countries" ? Writing each iso code in the world could be exhausting..
My code:
ItemFilter marketFilter = new ItemFilter();
marketFilter.setName(ItemFilterType.LISTED_IN);
marketFilter.getValue().add("EBAY-ENCA");
request.getItemFilter().add(marketFilter);
ItemFilter conditionFilter = new ItemFilter();
conditionFilter.setName(ItemFilterType.AVAILABLE_TO);
conditionFilter.getValue().add("UK");
request.getItemFilter().add(conditionFilter);
In general this call should work - regardless from where you call the API. So I assume that you get an error message from the API that prevent items from being returned. Be aware that the FindItemsAdvanced call of the eBay Finding API requires either a given "categoryId" or a "keyword". Do you set any of these?
Here is the XML payload of a working call:
<findItemsAdvancedRequest xmlns="http://www.ebay.com/marketplace/search/v1/services">
<keywords>iPhone6</keywords>
<itemFilter>
<name>ListedIn</name>
<value>EBAY-ENCA</value>
</itemFilter>
</findItemsAdvancedRequest>
I've created an example in our API playground. It uses the XML version of the Finding API. Just execute the call to see the valid response with items included. You can adapt and customize the request parameters to your needs and see how the API responses.
The "AvailableTo" filter can only be used once per request with exactly one value. So it won't be possible to add it multiple times or to add it once with multiple values. But I'm not sure if I get your use case right. Do you really want to get only those items that are available world wide? If yes, then I'm afraid this most probably isn't possible without filtering them locally (eg. by filtering for "Worldwide" in the "shipToLocations").
Situation: App has an API part and one of the API calls returns status of MongoDB. Right now it returns only "OK" or "DOWN".
final DB defaultDb = dbFactory.getDb(dbName);
Getting general status of DB from DB object is not a problem. But how I can get some more information? Like latency or other DB parameters? And is it possible to get more?
Take a look at the diagnostic commands in the reference: http://docs.mongodb.org/manual/reference/command/nav-diagnostic/
You can run any of those using DB.command(String) method.
EDIT: I have also found a CommandResult DB.getStats() method in the Java API.
You can use the ELK stack. For e.g., look here:
https://logz.io/blog/mongodb-performance-monitoring-elk-stack/