Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dan White 206 posts 510 karma points c-trib
    Dec 19, 2012 @ 01:51
    Dan White
    0

    Lucene RawQuery() searching every field in index

    So I have some code that generates a string to use in a Lucene RawQuery. Here's an example of my string:

    nodeName:(+John +Doe)^5 nodeName:John~0.6 Doe~0.6 firstName:(+John +Doe)^5 firstName:John~0.6 Doe~0.6 lastName:(+John +Doe)^5 lastName:John~0.6 Doe~0.6 bodyText:(+John +Doe)^5 bodyText:John~0.6 Doe~0.6 metaTitle:(+John +Doe)^5 metaTitle:John~0.6 Doe~0.6 metaDescription:(+John +Doe)^5 metaDescription:John~0.6 Doe~0.6

    The query that is generated after passing it into RawQuery is search ever field in the Examine Index. 

    { SearchIndexType: , LuceneQuery: nodeName:john doe~0.7 firstName:john doe~0.7 lastName:john doe~0.7 bodyText:john doe~0.7 metaTitle:john doe~0.7 metaDescription:john doe~0.7 (((+nodeName:john +nodeName:doe)^5.0) nodeName:john~0.6 (firstName:doe~0.6 lastName:doe~0.6 bodyText:doe~0.6 id:doe~0.6 nodeName:doe~0.6 updateDate:doe~0.6 writerName:doe~0.6 path:doe~0.6 nodeTypeAlias:doe~0.6 parentID:doe~0.6) ((+firstName:john +firstName:doe)^5.0) firstName:john~0.6 (firstName:doe~0.6 lastName:doe~0.6 bodyText:doe~0.6 id:doe~0.6 nodeName:doe~0.6 updateDate:doe~0.6 writerName:doe~0.6 path:doe~0.6 nodeTypeAlias:doe~0.6 parentID:doe~0.6) ((+lastName:john +lastName:doe)^5.0) lastName:john~0.6 (firstName:doe~0.6 lastName:doe~0.6 bodyText:doe~0.6 id:doe~0.6 nodeName:doe~0.6 updateDate:doe~0.6 writerName:doe~0.6 path:doe~0.6 nodeTypeAlias:doe~0.6 parentID:doe~0.6) ((+bodyText:john +bodyText:doe)^5.0) bodyText:john~0.6 (firstName:doe~0.6 lastName:doe~0.6 bodyText:doe~0.6 id:doe~0.6 nodeName:doe~0.6 updateDate:doe~0.6 writerName:doe~0.6 path:doe~0.6 nodeTypeAlias:doe~0.6 parentID:doe~0.6) ((+metaTitle:john +metaTitle:doe)^5.0) metaTitle:john~0.6 (firstName:doe~0.6 lastName:doe~0.6 bodyText:doe~0.6 id:doe~0.6 nodeName:doe~0.6 updateDate:doe~0.6 writerName:doe~0.6 path:doe~0.6 nodeTypeAlias:doe~0.6 parentID:doe~0.6) ((+metaDescription:john +metaDescription:doe)^5.0) metaDescription:john~0.6 (firstName:doe~0.6 lastName:doe~0.6 bodyText:doe~0.6 id:doe~0.6 nodeName:doe~0.6 updateDate:doe~0.6 writerName:doe~0.6 path:doe~0.6 nodeTypeAlias:doe~0.6 parentID:doe~0.6)) }

     

    I notice this is only happening when my search term includes a space. Any ideas?

  • Dan White 206 posts 510 karma points c-trib
    Dec 19, 2012 @ 23:14
    Dan White
    0

    I think I solved it. I'm new to all this, so I'm not exactly sure why, but wrapping my search terms within parathensis seemed to fix it.

    Here's a simplified version of what it was before:

    nodeName:(+John +Doe)^5 nodeName:John~0.5 Doe~0.5

    Which caused every field in the index to be searched

    Changing to this fixed it:

    nodeName:(+John +Doe)^5 nodeName:(John~0.5 Doe~0.5)
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies