Custom search and indexingCustom search and indexinghttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1173812682024-03-29T12:07:42Z2024-03-29T12:07:42ZRE: Custom search and indexingali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1175154332019-10-19T17:25:49Z2019-10-19T17:25:49ZYou didn't comment on the code I sent you<br />Do I filter the search result myself, right?ali yeganeh2019-10-19T17:25:49ZRE: Custom search and indexingali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174819462019-10-17T16:33:39Z2019-10-17T16:33:39Z<div class="quote-title">Olaf Kock:</div><blockquote><br />One of my suggestions was rather to add your myEntries ids to the keywords that you're searching in. In the case of 40000 results and 7 elements in myEntries, that would be a better option. <br />Sorry, no code sample</blockquote><br /><strong>How do I set an array of IDs for Search Context and then search on that array will happen through a keyword that the user enters?</strong>ali yeganeh2019-10-17T16:33:39ZRE: Custom search and indexingOlaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174710732019-10-16T17:24:30Z2019-10-16T17:24:30ZOne of my suggestions was rather to add your myEntries ids to the keywords that you're searching in. In the case of 40000 results and 7 elements in myEntries, that would be a better option. <br />Sorry, no code sampleOlaf Kock2019-10-16T17:24:30ZRE: Custom search and indexingali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174657002019-10-16T10:47:04Z2019-10-16T10:47:04Z<html><head></head><body>According to your description, i have done your alternative solution , i have 40000 search result and an array with 7 entries.<br>Afterward i compare these arrays to restrict my result,<u><strong> this is a good idea to solve my problem?</strong></u><br><u><strong>my code is:</strong></u><br><u><strong></strong></u><br><pre><code>
//array has 7 entities
long[] myEntities&nbsp; = { 1, 2, 3, 4, 5, 6, 7 };
// ids returns 40000 entities
searchContext.setKeywords( keywords );
Indexer indexer = IndexerRegistryUtil.getIndexer( Importation.class );
Hits hits = indexer.search( searchContext );
List<long>&nbsp;&nbsp;ids &nbsp; = new ArrayList&lt;&gt;();
for ( int i = 0 ; i &lt; hits.getDocs().length ; i++ )
{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Document doc = hits.doc( i );
&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; long entryId = GetterUtil.getLong( doc.get( Field.ENTRY_CLASS_PK ) );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ids .add( entryId );
}
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
//i compare two above results for restrict search result
List<long> list = new ArrayList&lt;&gt;();
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
for ( int i = 0 ; i &lt; myEntities&nbsp; .length ; i++ )
&nbsp;&nbsp; &nbsp;if (&nbsp; ids &nbsp; .contains( myEntities[i] ) )
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;list.add( myEntities&nbsp; [i] );
</long></long></code></pre><br><br> would you mind suggesting any idea if my solution is not efficient?<br>I want to use<a href="https://portal.liferay.dev/docs/7-2/frameworks/-/knowledge_base/f/search-queries-and-filters#queries-and-filters-in-liferays-search-api"> Queries and Filters in Liferay’s Search API </a><br>please give me a sample or a document for using in this problem.</body></html>ali yeganeh2019-10-16T10:47:04ZRE: Custom search and indexingOlaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174449862019-10-14T10:38:43Z2019-10-14T10:38:43ZYou've posted some code for searching one keyword - if that weird suggestion of adding the IDs that you want to search amongst to the query, you'd just have a couple of extra keywords.<br />As an alternative: Search in everything, then filter afterwards. It all depends on the raw numbers: For searching among 4 entries you'd choose a different strategy than for searching in 40000 entries.Olaf Kock2019-10-14T10:38:43ZRE: Custom search and indexingali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174438142019-10-14T07:47:44Z2019-10-14T07:47:44ZHi Mr. Olaf Kock<br />I still didn't get my answer<br />Please guide on my latest questionali yeganeh2019-10-14T07:47:44ZRE: Custom search and indexingali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174193282019-10-09T18:15:17Z2019-10-09T18:15:17ZCan I use liferay apis for build a search query and obtain search hits that match the query. <br />According to my problem that I want to<strong> </strong><u><strong>Search among specific data</strong> <strong>of a table</strong></u><br />if your answer is yes, please send me a sample code ?ali yeganeh2019-10-09T18:15:17ZRE: Custom search and indexingOlaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174112462019-10-09T10:29:47Z2019-10-09T10:29:47Z<div class="quote-title">ali yeganeh:</div><blockquote><br />What do you me it can quickly turn into an abuse of the search server ?<br /></blockquote>Your example contains 4 out of the 10 available ids to search in. If you search for 1 keyword in 40% of the available 1.000.000 documents, your keyword query will explode, e.g. you'll search for 400.001 keywords (if you make the ids keywords).<br />If you continue to search among 4 documents out of 1.000.000, you don't really need a search server, but can just validate individually.<br />And for anything in between: "it depends". <br />Maybe it's time to ask for the underlying business problem: How will this manifest on the user interface?Olaf Kock2019-10-09T10:29:47ZRE: Custom search and indexingali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174085592019-10-09T08:50:55Z2019-10-09T08:50:55ZWhat do you me it can quickly turn into an abuse of the search server ?<br />how can it possible ?<br />How can apply this solution in your answer ?ali yeganeh2019-10-09T08:50:55ZRE: Custom search and indexingOlaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174081742019-10-09T07:34:16Z2019-10-09T07:34:16Z<html><head></head><body><div class="quote-title">ali yeganeh:</div><blockquote><br>Now , I only used one keyword as criteria <br><pre><code>
SearchContext searchContext = SearchContextFactory.getInstance( request );
searchContext.setKeywords( keywords );
Hits hits = indexer.search( searchContext );
</code></pre><br>In the above source code I want set list of ID's to searchContext as a filter parameter<br><strong>Is there a method on searchContext for restricting result by an array of ID's ?</strong></blockquote>If the ids in question are also indexed as keywords, that seems possible indeed. It feels like it can quickly turn into an abuse of the search server, but possible: My vote is "yes"</body></html>Olaf Kock2019-10-09T07:34:16ZRE: Custom search and indexingali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174041202019-10-08T12:54:51Z2019-10-08T12:54:51Z<html><head></head><body>Now , I only used one keyword as criteria <br><pre><code>
SearchContext searchContext = SearchContextFactory.getInstance( request );
searchContext.setKeywords( keywords );
Hits hits = indexer.search( searchContext );
</code></pre><br>In the above source code I want set list of ID's to searchContext as a filter parameter<br><strong>Is there a method on searchContext for restricting result by an array of ID's ?</strong></body></html>ali yeganeh2019-10-08T12:54:51ZRE: Custom search and indexingOlaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1174017092019-10-08T10:11:42Z2019-10-08T10:11:42Z<div class="quote-title">ali yeganeh:</div><blockquote><br /><strong>Can I explicitly specify between what records to search?</strong> <strong></strong><br /></blockquote>On Elasticsearch, using the ES API? On Liferay's User Interface, using additional search terms? Is there any specific criteria for specifying the records you're searching in?Olaf Kock2019-10-08T10:11:42ZRE: Custom search and indexingali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1173990252019-10-08T09:14:37Z2019-10-08T09:14:37Z<div class="quote-title">ali yeganeh:</div><blockquote><br /><br />Assume I have a table<br />I want to search in this table, but only in restricted list of data<br />For example:<br />My table have this data: [1,2,3,4,5,6,7,8,9,10]<br />And my restricted list of data is [5,8,9,10]<br /><strong>I want to search only on restricted list [5,8,9,10]</strong><br /></blockquote><strong></strong><br /><strong></strong> Hi dear Olaf Kock<br /><strong>Can I explicitly specify between what records to search?</strong> <strong></strong>ali yeganeh2019-10-08T09:14:37ZRE: Custom search and indexingOlaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1173942642019-10-08T07:49:54Z2019-10-08T07:49:54ZIf I understand you correctly: As the search index typically doesn't have the same permissions model as the application (Liferay) does: You'd typically search on everything, but - before you present the result - filter by permissions.Olaf Kock2019-10-08T07:49:54ZRE: Custom search and indexingOlaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1173837802019-10-07T06:29:38Z2019-10-07T06:29:38ZCrossreferencing <a href="https://liferay.dev/forums/-/message_boards/message/117336794">a crosspost</a>. Don't crosspost!Olaf Kock2019-10-07T06:29:38ZRE: Custom search and indexingali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1173826932019-10-06T06:36:16Z2019-10-06T06:36:16ZHi David <br />Assume I have a table<br />I want to search in this table, but only in restricted list of data<br />For example:<br />My table have this data: [1,2,3,4,5,6,7,8,9,10]<br />And my restricted list of data is [5,8,9,10]<br /><strong>I want to search only on restricted list [5,8,9,10]</strong>ali yeganeh2019-10-06T06:36:16ZRE: Custom search and indexingDavid H Nebingerhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1173823522019-10-06T02:41:50Z2019-10-06T02:41:50ZI'm not really sure what you are asking about...<br /><br />The indexing and search link you pointed to is for indexing your documents into elastic and allowing that to be used during search, part of asset-enabling your entities.<br /><br />But then separately you're talking about doing queries based upon joins across it sounds like multiple tables, I'm assuming you're talking about doing an SQL query of some kind.<br /><br />And "search the part of the table data that belongs to a particular user"? I'm guessing you are trying to say you want to do a query against a table where a user id column matches a value?<br /><br />Sorry, but you're seemingly like all over the place about what you want?David H Nebinger2019-10-06T02:41:50ZRE: Custom search and indexingali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1173819572019-10-05T16:15:55Z2019-10-05T16:15:55ZHi David H Nebinger<br />What is your suggestion for me to be able to search the part of the table data that belongs to a particular user?ali yeganeh2019-10-05T16:15:55ZRE: Custom search and indexingDavid H Nebinge