SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye

Welcome, Guest
Guest Settings
Help

Compass Support Forums » Compass » Compass Users

Thread: Property with Index.NO and nonetheless searchable

This question is answered.


Permlink Replies: 2 - Pages: 1 - Last Post: Jan 30, 2008 10:29 AM Last Post By: darthvader
darthvader

Posts: 8
Registered: 6/26/06
Property with Index.NO and nonetheless searchable
Posted: Jan 30, 2008 8:53 AM
 
  Click to reply to this thread Reply
Hi,

assume a bean having a property with index=Index.NO:

@Searchable
@SearchableConstant(name = "type", values = {"bean"})
public class TestBean {
	
	private int id;
	private String text;
	private String actionLink;
	
	@SearchableId
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	@SearchableProperty
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
 
	@SearchableProperty(index=Index.NO)
	public String getActionLink() {
		return actionLink;
	}
	public void setActionLink(String actionLink) {
		this.actionLink = actionLink;
	}
 
}


In a unit test, I try to verify that the property "actionLink" is not searchable:
		TestBean testBean = new TestBean();
		testBean.setId(1);
		testBean.setActionLink("abc");
		testBean.setText("some searchable string");
		compassTemplate.save(testBean);
		
		CompassDetachedHits result = compassTemplate.findWithDetach("searchable");
		Assert.assertEquals(1, result.getLength());  // succeeds
		result = compassTemplate.findWithDetach("abc");
		Assert.assertEquals(0, result.getLength());  // fails, 1 result is found


I thought, setting a property to index=Index.NO prevents it from being used during search. Why is the given object being found?
What do I miss here?

Thanks,
Stefan
Shay Banon

Posts: 4,028
Registered: 9/6/05
Re: Property with Index.NO and nonetheless searchable
Posted: Jan 30, 2008 10:05 AM   in response to: darthvader in response to: darthvader
Correct
  Click to reply to this thread Reply
When you search like that, it actually translates to a query string: all:searchable. Even though you set the property not to be indexed, it will be added to the all property. You set it to be excluded from all as well.
darthvader

Posts: 8
Registered: 6/26/06
Re: Property with Index.NO and nonetheless searchable
Posted: Jan 30, 2008 10:29 AM   in response to: Shay Banon in response to: Shay Banon
 
  Click to reply to this thread Reply
Thanks a lot, Shay! When mapping with
@SearchableProperty(index=Index.NO,excludeFromAll=true)
it is not searchable, exactly what I need here.
Legend
Guru: 2001 + pts
Expert: 501 - 2000 pts
Super-star: 101 - 500 pts
Assistant: 51 - 100 pts
Participant: 0 - 50 pts
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums