Regarding FullText Search

115 views
Skip to first unread message

gokulakanna balakrishnan

unread,
Jul 3, 2012, 5:11:43 PM7/3/12
to ne...@googlegroups.com
Hi All,

   I am implement fulltext search in application. I am trying to do pagination for that I need number of mathing record.
I have wrote following queries for gettting matching count. But I am getting exception.

public class Team{

@Indexed(indexType=IndexType.FULLTEXT, indexName = "teamSearch")
private String searchTeamName;
...
...
}
 

@Query("start team=node:__types__(className=\"com.letzplay.domain.Team\")(searchTeamName = {0}) return count(team)")
    public Integer getCountBySearchTeam(String name);


Exception:

org.springframework.dao.InvalidDataAccessResourceUsageException: Error executing statement start team=node:__types__(className="com.letzplay.domain.Team")(searchTeamName = {0}) return count(team); nested exception is expected return clause "start team=node:__types__(className="com.letzplay.domain.Team")(searchTeamName = {0}) return count(team)" ^


@Query("start team=node:__types__(className=\"com.letzplay.domain.Team\") where team.searchTeamName={0} return count(team)")
public Integer getCountBySearchTeam(String name);

Exception: NullPointerException throwing.


Please help me fix above issue. Last two days I am struggling to fix this problem.

Thanks & Regards,
Gokul

Michael Hunger

unread,
Jul 3, 2012, 7:53:24 PM7/3/12
to ne...@googlegroups.com
@Query("start team=node:searchTeamName({0}) return count(team)")
public Integer getCountBySearchTeam(String searchQuery);

you have to pass in: "searchTeamName:searchterm" as parameter to the method.

MIchael

gokulakanna balakrishnan

unread,
Jul 4, 2012, 9:32:41 AM7/4/12
to ne...@googlegroups.com
Hi Michael,

Thanks alot for helping me Michael.

I have modified full text search query. I am getting null pointer
exception. I have added my source code below.

@NodeEntity
public Team
{

@Indexed(indexType=IndexType.FULLTEXT, indexName = "teamSearch")
private String searchTeamName;
}


public interface TeamRepository extends
GraphRepository<Team>,NamedIndexRepository<Team>,RelationshipOperationsRepository<Team>
{

@Query("start team=node:searchTeamName({0}) return count(team)")
public Integer getCountBySearchTeam(String searchQuery);

}


@ParentPackage(value = "letzplay")
public SearchAction
{

public String search() throws Exception {

int count=teamRepository.getCountBySearchTeam("searchTeamName:"+name);
}
}


Exception: NullPointerException

Thanks & Regards,
Gokul

Michael Hunger

unread,
Jul 4, 2012, 10:04:08 AM7/4/12
to ne...@googlegroups.com
Can you make the int count into a Integer count = …

Do you have a full stacktrace for the exception?

Thanks

Michael

gokulakanna balakrishnan

unread,
Jul 4, 2012, 10:28:38 AM7/4/12
to ne...@googlegroups.com
Hi Michael,

After changing into integer its not throwing exception. But
search result is coming as null. But data is in the database.

Thanks & Regards,
Gokul

gokulakanna balakrishnan

unread,
Jul 4, 2012, 10:50:08 AM7/4/12
to ne...@googlegroups.com
Hi Michael,

teamRepository.findBySearchTeamNameLike(name) - is returning
result for same search criteria.

Thanks & Regards,
Gokul

Michael Hunger

unread,
Jul 4, 2012, 11:42:52 AM7/4/12
to ne...@googlegroups.com
Your index name in the cypher query is wrong

It must be node:teamSearch

Sent from mobile device

gokulakanna balakrishnan

unread,
Jul 6, 2012, 8:33:36 AM7/6/12
to ne...@googlegroups.com
Hi Michael,

Thanks alot. Its working fine.

Thanks & Regards,
Gokul
Reply all
Reply to author
Forward
0 new messages