Lucene Autocomplete in JSON data - java

I am trying to build a search engine using Neo4j as backend & Java web application as frontend. Using Neo4j Java API, the data extracted is in JSON format. Any idea how to query the JSON data using Lucene for providing autocomplete suggestions to the user ???

Suggest lucene
Check this thread I used this to create my autocomplete and richfaces for display this

For autocomplete there's a very helpful new feature in 2.3:
MATCH (n:Person)
WHERE n.name starts with 'Jo'
RETURN n
returns person nodes like 'John' and 'Joanne' based on a index search.
Of course the index has be created using
CREATE INDEX ON :Person(name)

Related

Script fields in hibernate elasticsearch

I'm using hibernate-search-elasticsearch 5.8.2.Final and I can't figure out how to get script fields:
https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-script-fields.html
Is there any way to accomplish this functionality?
This is not possible in Hibernate Search 5.8.
In Hibernate Search 5.10 you could get direct access to the REST client, send a REST request to Elasticsearch and get the result as a JSON string that you would have to parse yourself, but it is very low-level and you would not benefit from the Hibernate Search search APIs at all (no query DSL, no managed entity loading, no direct translation entity type => index name, ...).
If you want better support for this feature, don't hesitate to open a ticket on our JIRA, describing in details what you are trying to achieve and how you would have expected to be able to do that. We are currently working on Search 6.0 which brings a lot of improvements, in particular when it comes to using native features of Elasticsearch, so it just might be something we could slip into our backlog.
EDIT: I forgot to mention that, while you cannot use server-side scripts, you can still get the full source from your documents, and do some parsing in your application to achieve a similar result. This will work even in Search 5.8:
FullTextEntityManager fullTextEm = Search.getFullTextEntityManager(entityManager);
FullTextQuery query = fullTextEm.createFullTextQuery(
qb.keyword()
.onField( "tags" )
.matching( "round-based" )
.createQuery(),
VideoGame.class
)
.setProjection( ElasticsearchProjectionConstants.SCORE, ElasticsearchProjectionConstants.SOURCE );
Object[] projections = (Object[]) query.getSingleResult();
for (Object projection : projections) {
float score = (float) projection[0];
String source = (String) projection[1];
}
See this section of the documentation.

In AEM query builder order by based on someproperty=somevalue

I m trying to sort the AEM query builder search results based on particular value of particular property. as we have in any database like MySQL we can sort based on column's value as well (for exp. ORDER BY FIELD('columnName','anyColumnName'). can we have something like this in AEM.
Suppose we have 5 Assets under path /content/dam/Assets.
Asset Name------------dc:title
1.jpg------------------Apple
2.jpg------------------Cat
3.jpg------------------Cat
4.jpg------------------Ball
5.jpg------------------Drag
I need assets on top of the results where dc:title = cat and also need other results also in sorting asc. expected result as given below
2.jpg------------------Cat
3.jpg------------------Cat
1.jpg------------------Apple
4.jpg------------------Ball
5.jpg------------------Drag
Note:- Using version AEM 6.2
You can use the orderby predicate with a value of #jcr:content/metadata/dc:title to sort by dc:title with the QueryBuilder. /libs/cq/search/content/querydebug.html is an interface to test queries on your instance. ACS Commons has a good breakdown of all out of the box predicates
If you want to pull Cats to the top of the results with a single query, you could write a custom predicate. The sample code from ACS Commons shows an example. Adobe has documentation as well.

How to get case-insensitive result with exact match in elastic search jhipster project

On working with Jhipster project with spring boot- 1.4.0-RELEASE and elastic search-2.3.5.
When I index data with analyzed then on search with different query builders, it result differently and incorrectly. But on changing the indexing to not_analyzed then most of the filter works fine except the search is case-sensitive.
To not_analyzed data we have added this annotation on entity class string fields :
#Field(type = FieldType.String, index = FieldIndex.not_analyzed, store = true)
The operators on which I have to perform search are :
Is
IsNot
IsOneOf
IsNotOneOf
Contains
DoesNotContains
StartsWith
EndsWith
So with not_analyzed index, it return correct result except case-sensitivity of searched string.
On researching, we found that we can use keyword analyzer with tokenizer lower case to perform search, I have searched but all return solution with lucene spring or elastic search queries. I want solution using spring boot elastic search. How can we apply this in annotation or while sending search request.
We want to make the search case-insensitive but it should give correct result for all operators. Is there any way?

Fusion Table API : query don't get <innerBoundaryIs> elements in Location column

I'm trying to get the contents of a Fusion Table Location column
This column contains a Polygon with "outerBoundaryIs" and "innerBoundaryIs"
I'm querying the column with Fusion Tables API Query:sql, but the response don't get the "innerBoundaryIs" elements
I'm using the Fusion Tables Java Library v1r33lv1.15.0-rc
Any direction is appreciated
LluĂ­s
Set the typed-parameter to false (default is true)
<edit>:
I don't know why(I haven't found anything about this in any documentation), but for me it works when I add a linebreak after the closing </outerBoundaryIs>
Demo: http://jsfiddle.net/doktormolle/LsCLV/ (it's a copy of your table, the only difference is the linebreak)
The query from the Fusion Tables API will not return KML. Look at the documentation for what the 2 types (JSON, CSV) will look like, neither includes the InnerBoundaryIs (or outerBoundaryIs) elements.
If you need the KML, it will be returned if you use the google visualization query, but that is limited to returning 500 rows.
Query using Fusion Tables API v1.0 and parse response to native Google Maps Javascript API v3 objects

Can I use a manually created index and query nodes using Cypher?

Here I have created a manual/legacy index and added some nodes with certain properties into it.
IndexManager indexy = graphdb.index();
Index<Node>indexery = indexy.forNodes("Main_Twitter_Index");
indexery.add(one,"Name",one.getProperty("Name"));
indexery.add(one,"Email",one.getProperty("Email"));
indexery.add(four,"Name",four.getProperty("Name"));
indexery.add(four,"Email",four.getProperty("Email"));
Now, to query the nodes of that index neo4j suggests query, which uses a key-value pair binding. My question is can I query the same nodes added into the manual index using a simple cypher query like,
START n=node:Main_Twitter_Index(Name = 'Akina')
RETURN n
Which version of Neo4j are you using? The method you describe is the typical index search for anything before 2.0, before they added schema indexing. Your query should work, even in 2.0. Are you having problems running it?

Categories

Resources