I am trying to get files results using SearchExecutor.
This us the code:
using (SPSite site = new SPSite("http://SERVER NAME"))
{
using (SPWeb web = site.OpenWeb(""))
{
KeywordQuery keywordQuery = new KeywordQuery(web);
keywordQuery.QueryText = "Author: Moss_User";
keywordQuery.KeywordInclusion = KeywordInclusion.AllKeywords;
keywordQuery.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default;
keywordQuery.TrimDuplicates = false;
keywordQuery.EnableStemming = true;
keywordQuery.EnablePhonetic = true;
keywordQuery.EnableNicknames = false;
keywordQuery.IgnoreAllNoiseQuery = true;
keywordQuery.Timeout = 60000;
keywordQuery.RowLimit = 500;
keywordQuery.SelectProperties.Add("author");
keywordQuery.SelectProperties.Add("SiteName");
SearchExecutor searchExecutor = new SearchExecutor();
ResultTableCollection resultTableCollection = searchExecutor.ExecuteQuery(keywordQuery);
var resultTables = resultTableCollection.Filter("TableType", KnownTableTypes.RelevantResults);
var resultTable = resultTables.FirstOrDefault();
retunltDataTable = resultTable.Table;
}}
The thing is I am not getting ANY results when searching for:
keywordQuery.QueryText ="Author: Moss_User"
I am getting resukts only when searching for:
keywordQuery.QueryText ="*"
What can be the problem?
Just remove that whitespace after colon
keywordQuery.QueryText ="Author:Moss_User"
Also there is tool for testing queries against Sharepoint search API, it can be useful for testing queries without deploying any code
Sharepoint Search Tool
Related
I'm using Lucene.Net 4.8.0-beta00016 version and using .Net 6.0.
When i write to RAMDirectory i'm able to fetch FastTaxonomyFacetCounts if i try to fetch from Directory (File System) it is throwing Index Corrupted. Missing parent data for category 0.
Below is the code which I'm facing issue. IndexDirectory and TaxoDirectory is the physical file path where lucene indexes generated.
using (DirectoryReader indexReader = DirectoryReader.Open(IndexDirectory))
using (DirectoryTaxonomyReader taxoReader = new DirectoryTaxonomyReader(TaxoDirectory))
{
IndexSearcher searcher = new IndexSearcher(indexReader);
FacetsCollector fc = new FacetsCollector();
Query q = new WildcardQuery(new Term("Brand", "*Ji*"));
TopScoreDocCollector tdc = TopScoreDocCollector.Create(10, true);
var topDocs = FacetsCollector.Search(searcher, q, 10, fc);
var topHits = topDocs.ScoreDocs;
var hits = searcher.Search(q, 10, Sort.INDEXORDER).ScoreDocs;
if (hits != null)
{
foreach (var hit in hits)
{
var document = searcher.Doc(hit.Doc);
}
}
Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, fc);
var result = facets.GetAllDims(1000);
}
If anyone has solution. Please guide me
It should return Facets.
I am updating journal entry on Net suite using suite talk API.
I can add new lines for the record. but on updating existing line using line ID in am getting below error.
You do not have permissions to set a value for element line.line due to one of the following reasons: 1) The field is read-only; 2) An associated feature is disabled; 3) The field is available either when a record is created or updated, but not in both cases.
i can update lines using GUI but not using API
NetSuiteServiceBridge nsServiceBridge = NetSuiteServiceBridge.serviceInstance;
JournalEntry j = new JournalEntry();
//j.subsidiary =new RecordRef {internalId="2",type=RecordType.subsidiary };
j.internalId = "115939";
JournalEntryLineList jl = new JournalEntryLineList();
JournalEntryLine line1 = new JournalEntryLine();
line1.startDate = DateTime.Now;
line1.startDateSpecified = true;
line1.line = 5;
line1.lineSpecified = true;
line1.account = new RecordRef { internalId = "206", type = RecordType.account };
line1.department = new RecordRef { internalId = "1", type = RecordType.department };
line1.credit = 100;
line1.creditSpecified = true;
jl.line = new JournalEntryLine[] {line1};
jl.replaceAll = false;
j.lineList = jl;
WriteResponse r= nsServiceBridge.UpdateRecords(j);
Web Services has its own permissions separate the the native GUI
This is by design
I have an Amazon EC2 instance and I need to be able to create an AMI (image) from it programmatically. I'm trying the following:
CreateImageRequest rq = new CreateImageRequest();
rq.InstanceId = myInstanceID;
rq.Name = instance.KeyName;
rq.Description = "stam";
rq.NoReboot = true;
IAmazonEC2 ec2;
AmazonEC2Config ec2conf = new AmazonEC2Config();
ec2 = AWSClientFactory.CreateAmazonEC2Client(ec2conf);
// CreateImageResponse imageResp;
Amazon.EC2.Model.CreateImageResponse imageResp = null;
try
{
imageResp = ec2.CreateImage(rq);
}
catch (AmazonServiceException ase)
{
MessageBox.Show(ase.Message);
}
The result is always an AmazonServiceException saying that there is a NameResolutionFailure.
How do I overcome this? I tried different possible "name" possibilities but cannot find the right one.
string amiID = ConfigurationManager.AppSettings[AmazonConstants.AwsImageId];
string keyPairName = ConfigurationManager.AppSettings[AmazonConstants.AwsKeyPair];
List<string> groups = new List<string>() { ConfigurationManager.AppSettings[AmazonConstants.AwsSecurityGroupId] };
var launchRequest = new RunInstancesRequest()
{
ImageId = amiID,
InstanceType = ConfigurationManager.AppSettings[AmazonConstants.AwsInstanceType],
MinCount = 1,
MaxCount = 1,
KeyName = keyPairName,
SecurityGroupIds = groups,
SubnetId = ConfigurationManager.AppSettings[AmazonConstants.AwsSubnetId]
};
RunInstancesResponse runInstancesResponse = amazonEc2client.RunInstances(launchRequest);
RunInstancesResult runInstancesResult = runInstancesResponse.RunInstancesResult;
Reservation reservation = runInstancesResult.Reservation;
Problem eventually solved!
it turned out thyat some codelines were doing things which were already done already and removing this part:
IAmazonEC2 ec2;
AmazonEC2Config ec2conf = new AmazonEC2Config();
ec2 = AWSClientFactory.CreateAmazonEC2Client(ec2conf);
// CreateImageResponse imageResp;
Amazon.EC2.Model.CreateImageResponse imageResp = null;
Made things clearer and no wrong repetitions happened! Now it works!
I am bringing in a query from TFS into an application I wrote in C#. Everything is working fine except I cannot access certain fields from the query. They don't show up. I think perhaps they are most likely custom fields added to our project. For example: The build version number... In the TFS query, the field is called ObjectVersion. But I cannot use it, it doesn't exist in my code.
This is what I have. The TFSCheckIter() method just converts the iterationpath to something that my C# program recognizes, "TFSitemIteration". The lines Commented out are the Fields that I cant access.
Uri collectionUri = new Uri("http://Server/tfs/DefaultCollection/");
NetworkCredential credential = new NetworkCredential("UserName", "Password");
TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(collectionUri, credential);
teamProjectCollection.EnsureAuthenticated();
WorkItemStore workItemStore = teamProjectCollection.GetService<WorkItemStore>();
var togProject = workItemStore.Projects.OfType<Project>().FirstOrDefault(project => project.Name == "ProjectName");
if (togProject != null)
{
var CMRAQuery = togProject.StoredQueries.OfType<StoredQuery>().FirstOrDefault(query => query.Name == "TFSBuildTasks");
if (CMRAQuery != null)
{
WorkItemCollection WrkItmLst = workItemStore.Query(CMRAQuery.QueryText.Replace("#project", "\"ProjectName\"").Replace("#me", "\"Name\""));
foreach (WorkItem TFSitem in WrkItmLst)
{
TFSitemName = TFSitem.Title;
//TFSitemVersion = TFSitem.ObjectVersion;
//TFSitemType = TFSitem.ObjectType;
TFSitemState = TFSitem.State;
TFSitemIterPath = TFSitem.IterationPath;
//TFSitemconfig = TFSitem.IncludeConfig;
//TFSitemLB = TFSitem.LoadBalancer;
//TFSitemFW = TFSitem.Framework;
TFSCheckIter();
if (TFSitemState == "D-Promote" | TFSitemState == "I-Promote")
{
label5.Text = TFSitemName;
label6.Text = TFSitemState;
label7.Text = TFSitemIteration;
label8.Text = TFSitemVersion;
}
}
}
}
Use the Fields property TFSitemVersion = TFSitem.Fields['ObjectVersion'].Value. I suggest to use the Reference Name, e.g. YourCompany.ObjectVersion.
I have to fetch Work Order record from NetSuite based on work order number, I can do that using a saved search but would like to do it without it, so as i do not have a to create another saved search record in production. My code is not returning any result, however the search is successful.
here is the code i am using:
TransactionSearch ts = new TransactionSearch();
TransactionSearchBasic tsb = new TransactionSearchBasic();
// work order number
SearchStringField sfTranId = new SearchStringField();
sfTranId.#operator = SearchStringFieldOperator.#is;
sfTranId.searchValue = workorder;
sfTranId.operatorSpecified = true;
// type
SearchEnumMultiSelectField sfType = new SearchEnumMultiSelectField();
sfType.#operator = SearchEnumMultiSelectFieldOperator.anyOf;
sfType.operatorSpecified = true;
sfType.searchValue = new String[] {"_workOrder"};
tsb.tranId = sfTranId;
tsb.type = sfType;
ts.basic = tsb;
tsa3.criteria = ts;
// perform the search
SearchResult res = _service.search(ts);
res.pageSizeSpecified = true;
if (res.status.isSuccess)
{
SearchRow[] searchRows = res.searchRowList;
if (searchRows != null && searchRows.Length >= 1)
{
TransactionSearchRow tranRow = (TransactionSearchRow)searchRows[0];
if (tranRow.basic.internalId != null && tranRow.basic.internalId.Length > 0)
{
woResult = tranRow.basic.internalId[0].searchValue.internalId;
}
}
}
I realized my mistake, basic search returns RecordList and not SearchRowList.